From bc82c6ebd7b9ba31437f3dcf34064106749edcf7 Mon Sep 17 00:00:00 2001 From: Nikolas Date: Mon, 24 Feb 2025 16:44:40 +0100 Subject: [PATCH] Move from sentinel-terminated pointers to sentinel-terminated slices globally ([+:0] -> [:0]) (#203) --- examples/shapes/colors_palette.zig | 2 +- lib/generate_functions.py | 4 +- lib/preludes/raylib-prelude.zig | 96 ++++++------ lib/raygui.zig | 68 ++++----- lib/raylib.zig | 236 ++++++++++++++--------------- lib/rlgl.zig | 12 +- 6 files changed, 209 insertions(+), 209 deletions(-) diff --git a/examples/shapes/colors_palette.zig b/examples/shapes/colors_palette.zig index 1d7bc37..09763a3 100644 --- a/examples/shapes/colors_palette.zig +++ b/examples/shapes/colors_palette.zig @@ -43,7 +43,7 @@ pub fn main() anyerror!void { rl.Color.beige, }; - const colorNames = [maxColorCount][*:0]const u8{ + const colorNames = [maxColorCount][:0]const u8{ "DARKGRAY", "MAROON", "ORANGE", diff --git a/lib/generate_functions.py b/lib/generate_functions.py index d347817..a6773fb 100755 --- a/lib/generate_functions.py +++ b/lib/generate_functions.py @@ -73,7 +73,7 @@ def ziggify_type(name: str, t: str, func_name) -> str: string = False if name == "text" and t == "[*c][*c]const u8": - return "[][*:0]const u8" + return "[][:0]const u8" if t.startswith("[*c]") and name not in single and name not in multi: if (t == "[*c]const u8" or t == "[*c]u8") and name not in NO_STRINGS: # Strings are multis. @@ -85,7 +85,7 @@ def ziggify_type(name: str, t: str, func_name) -> str: while t.startswith("[*c]"): t = t[4:] if string and not t.startswith("[*c]"): - pre += "[*:0]" + pre += "[:0]" elif name in single: pre += "*" else: diff --git a/lib/preludes/raylib-prelude.zig b/lib/preludes/raylib-prelude.zig index 6c2eb3f..b5285a5 100644 --- a/lib/preludes/raylib-prelude.zig +++ b/lib/preludes/raylib-prelude.zig @@ -850,17 +850,17 @@ pub const Image = extern struct { format: PixelFormat, /// Load image from file into CPU memory (RAM) - pub fn init(fileName: [*:0]const u8) RaylibError!Image { + pub fn init(fileName: [:0]const u8) RaylibError!Image { return rl.loadImage(fileName); } /// Load image from RAW file data - pub fn initRaw(fileName: [*:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) RaylibError!Image { + pub fn initRaw(fileName: [:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) RaylibError!Image { return rl.loadImageRaw(fileName, width, height, format, headerSize); } /// Load image sequence from file (frames appended to image.data) - pub fn initAnim(fileName: [*:0]const u8, frames: *i32) RaylibError!Image { + pub fn initAnim(fileName: [:0]const u8, frames: *i32) RaylibError!Image { return rl.loadImageAnim(fileName, frames); } @@ -880,12 +880,12 @@ pub const Image = extern struct { } /// Create an image from text (default font) - pub fn initText(text: [*:0]const u8, fontSize: i32, color: Color) RaylibError!Image { + pub fn initText(text: [:0]const u8, fontSize: i32, color: Color) RaylibError!Image { return rl.imageText(text, fontSize, color); } /// Create an image from text (custom sprite font) - pub fn initTextEx(font: Font, text: [*:0]const u8, fontSize: f32, spacing: f32, t: Color) RaylibError!Image { + pub fn initTextEx(font: Font, text: [:0]const u8, fontSize: f32, spacing: f32, t: Color) RaylibError!Image { return rl.imageTextEx(font, text, fontSize, spacing, t); } @@ -930,7 +930,7 @@ pub const Image = extern struct { } /// Generate image: grayscale image from text data - pub fn genText(width: i32, height: i32, text: [*:0]const u8) Image { + pub fn genText(width: i32, height: i32, text: [:0]const u8) Image { return rl.genImageText(width, height, text); } @@ -1145,22 +1145,22 @@ pub const Image = extern struct { } /// Draw text (using default font) within an image (destination) - pub fn drawText(self: *Image, text: [*:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void { + pub fn drawText(self: *Image, text: [:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void { rl.imageDrawText(self, text, posX, posY, fontSize, color); } /// Draw text (custom sprite font) within an image (destination) - pub fn drawTextEx(self: *Image, font: Font, text: [*:0]const u8, position: Vector2, fontSize: f32, spacing: f32, t: Color) void { + pub fn drawTextEx(self: *Image, font: Font, text: [:0]const u8, position: Vector2, fontSize: f32, spacing: f32, t: Color) void { rl.imageDrawTextEx(self, font, text, position, fontSize, spacing, t); } /// Export image data to file, returns true on success - pub fn exportToFile(self: Image, fileName: [*:0]const u8) bool { + pub fn exportToFile(self: Image, fileName: [:0]const u8) bool { return rl.exportImage(self, fileName); } /// Export image as code file defining an array of bytes, returns true on success - pub fn exportAsCode(self: Image, fileName: [*:0]const u8) bool { + pub fn exportAsCode(self: Image, fileName: [:0]const u8) bool { return rl.exportImageAsCode(self, fileName); } @@ -1186,7 +1186,7 @@ pub const Texture = extern struct { mipmaps: c_int, format: PixelFormat, - pub fn init(fileName: [*:0]const u8) RaylibError!Texture { + pub fn init(fileName: [:0]const u8) RaylibError!Texture { return rl.loadTexture(fileName); } @@ -1290,12 +1290,12 @@ pub const Font = extern struct { glyphs: [*c]GlyphInfo, /// Load font from file into GPU memory (VRAM) - pub fn init(fileName: [*:0]const u8) RaylibError!Font { + pub fn init(fileName: [:0]const u8) RaylibError!Font { return rl.loadFont(fileName); } /// Load font from file with extended parameters, use null for fontChars to load the default character set - pub fn initEx(fileName: [*:0]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { + pub fn initEx(fileName: [:0]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { return rl.loadFontEx(fileName, fontSize, fontChars); } @@ -1305,7 +1305,7 @@ pub const Font = extern struct { } /// Load font from memory buffer, fileType refers to extension: i.e. '.ttf' - pub fn fromMemory(fileType: [*:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { + pub fn fromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { return rl.loadFontFromMemory(fileType, fileData, fontSize, fontChars); } @@ -1320,7 +1320,7 @@ pub const Font = extern struct { } /// Export font as code file, returns true on success - pub fn exportAsCode(self: Font, fileName: [*:0]const u8) bool { + pub fn exportAsCode(self: Font, fileName: [:0]const u8) bool { return rl.exportFontAsCode(self, fileName); } }; @@ -1456,7 +1456,7 @@ pub const Model = extern struct { bindPose: [*c]Transform, /// Load model from file (meshes and materials) - pub fn init(fileName: [*:0]const u8) RaylibError!Model { + pub fn init(fileName: [:0]const u8) RaylibError!Model { return rl.loadModel(fileName); } @@ -1992,7 +1992,7 @@ pub fn setWindowIcons(images: []Image) void { } /// Load shader from files and bind default locations -pub fn loadShader(vsFileName: ?[*:0]const u8, fsFileName: ?[*:0]const u8) RaylibError!Shader { +pub fn loadShader(vsFileName: ?[:0]const u8, fsFileName: ?[:0]const u8) RaylibError!Shader { var vsFileNameFinal = @as([*c]const u8, 0); var fsFileNameFinal = @as([*c]const u8, 0); if (vsFileName) |vsFileNameSure| { @@ -2007,7 +2007,7 @@ pub fn loadShader(vsFileName: ?[*:0]const u8, fsFileName: ?[*:0]const u8) Raylib } /// Load shader from code strings and bind default locations -pub fn loadShaderFromMemory(vsCode: ?[*:0]const u8, fsCode: ?[*:0]const u8) RaylibError!Shader { +pub fn loadShaderFromMemory(vsCode: ?[:0]const u8, fsCode: ?[:0]const u8) RaylibError!Shader { var vsCodeFinal = @as([*c]const u8, 0); var fsCodeFinal = @as([*c]const u8, 0); if (vsCode) |vsCodeSure| { @@ -2022,7 +2022,7 @@ pub fn loadShaderFromMemory(vsCode: ?[*:0]const u8, fsCode: ?[*:0]const u8) Rayl } /// Load file data as byte array (read) -pub fn loadFileData(fileName: [*:0]const u8) RaylibError![]u8 { +pub fn loadFileData(fileName: [:0]const u8) RaylibError![]u8 { var bytesRead: i32 = 0; var res: []u8 = undefined; @@ -2035,12 +2035,12 @@ pub fn loadFileData(fileName: [*:0]const u8) RaylibError![]u8 { } /// Save data to file from byte array (write), returns true on success -pub fn saveFileData(fileName: [*:0]const u8, data: []u8) bool { +pub fn saveFileData(fileName: [:0]const u8, data: []u8) bool { return cdef.SaveFileData(@as([*c]const u8, @ptrCast(fileName)), @as(*anyopaque, @ptrCast(data.ptr)), @as(c_int, @intCast(data.len))); } /// Export data to code (.h), returns true on success -pub fn exportDataAsCode(data: []const u8, fileName: [*:0]const u8) bool { +pub fn exportDataAsCode(data: []const u8, fileName: [:0]const u8) bool { return cdef.ExportDataAsCode(@as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len)), @as([*c]const u8, @ptrCast(fileName))); } @@ -2095,21 +2095,21 @@ pub fn computeSHA1(data: []u8) [5]u32 { } /// Load image from file into CPU memory (RAM) -pub fn loadImage(fileName: [*:0]const u8) RaylibError!Image { +pub fn loadImage(fileName: [:0]const u8) RaylibError!Image { const image = cdef.LoadImage(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; } /// Load image from RAW file data -pub fn loadImageRaw(fileName: [*:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) RaylibError!Image { +pub fn loadImageRaw(fileName: [:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) RaylibError!Image { const image = cdef.LoadImageRaw(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, width), @as(c_int, height), format, @as(c_int, headerSize)); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; } /// Load image sequence from file (frames appended to image.data) -pub fn loadImageAnim(fileName: [*:0]const u8, frames: *i32) RaylibError!Image { +pub fn loadImageAnim(fileName: [:0]const u8, frames: *i32) RaylibError!Image { const image = cdef.LoadImageAnim(@as([*c]const u8, @ptrCast(fileName)), @as([*c]c_int, @ptrCast(frames))); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; @@ -2129,21 +2129,21 @@ pub fn loadImageFromScreen() RaylibError!Image { return if (isValid) image else RaylibError.LoadImage; } -pub fn loadImageAnimFromMemory(fileType: [*:0]const u8, fileData: []const u8, frames: *i32) RaylibError!Image { +pub fn loadImageAnimFromMemory(fileType: [:0]const u8, fileData: []const u8, frames: *i32) RaylibError!Image { const image = cdef.LoadImageAnimFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len)), @as([*c]c_int, @ptrCast(frames))); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; } /// Load image from memory buffer, fileType refers to extension: i.e. '.png' -pub fn loadImageFromMemory(fileType: [*:0]const u8, fileData: []const u8) RaylibError!Image { +pub fn loadImageFromMemory(fileType: [:0]const u8, fileData: []const u8) RaylibError!Image { const image = cdef.LoadImageFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len))); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; } /// Create an image from text (default font) -pub fn imageText(text: [*:0]const u8, fontSize: i32, color: Color) RaylibError!Image { +pub fn imageText(text: [:0]const u8, fontSize: i32, color: Color) RaylibError!Image { // TODO: ImageText requires SUPPORT_MODULE_RTEXT. Error out if not loaded. const image = cdef.ImageText(@as([*c]const u8, @ptrCast(text)), @as(c_int, fontSize), color); const isValid = cdef.IsImageValid(image); @@ -2151,7 +2151,7 @@ pub fn imageText(text: [*:0]const u8, fontSize: i32, color: Color) RaylibError!I } /// Create an image from text (custom sprite font) -pub fn imageTextEx(font: Font, text: [*:0]const u8, fontSize: f32, spacing: f32, tint: Color) RaylibError!Image { +pub fn imageTextEx(font: Font, text: [:0]const u8, fontSize: f32, spacing: f32, tint: Color) RaylibError!Image { // TODO: ImageTextEx requires SUPPORT_MODULE_RTEXT. Error out if not loaded. const image = cdef.ImageTextEx(font, @as([*c]const u8, @ptrCast(text)), fontSize, spacing, tint); const isValid = cdef.IsImageValid(image); @@ -2184,7 +2184,7 @@ pub fn loadImagePalette(image: Image, maxPaletteSize: i32) RaylibError![]Color { } /// Load texture from file into GPU memory (VRAM) -pub fn loadTexture(fileName: [*:0]const u8) RaylibError!Texture2D { +pub fn loadTexture(fileName: [:0]const u8) RaylibError!Texture2D { const texture = cdef.LoadTexture(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsTextureValid(texture); return if (isValid) texture else RaylibError.LoadTexture; @@ -2220,14 +2220,14 @@ pub fn getFontDefault() RaylibError!Font { } /// Load font from file into GPU memory (VRAM) -pub fn loadFont(fileName: [*:0]const u8) RaylibError!Font { +pub fn loadFont(fileName: [:0]const u8) RaylibError!Font { const font = cdef.LoadFont(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsFontValid(font); return if (isValid) font else RaylibError.LoadFont; } /// Load font from file with extended parameters, use null for fontChars to load the default character set -pub fn loadFontEx(fileName: [*:0]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { +pub fn loadFontEx(fileName: [:0]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { var fontCharsFinal = @as([*c]c_int, 0); var fontCharsLen: c_int = @as(c_int, 0); if (fontChars) |fontCharsSure| { @@ -2240,7 +2240,7 @@ pub fn loadFontEx(fileName: [*:0]const u8, fontSize: i32, fontChars: ?[]i32) Ray } /// Load font from memory buffer, fileType refers to extension: i.e. '.ttf' -pub fn loadFontFromMemory(fileType: [*:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { +pub fn loadFontFromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { var fileDataFinal = @as([*c]const u8, 0); var fileDataLen: i32 = 0; if (fileData) |fileDataSure| { @@ -2273,7 +2273,7 @@ pub fn loadFontData(fileData: []const u8, fontSize: i32, fontChars: []i32, ty: F } /// Load all codepoints from a UTF-8 text string, codepoints count returned by parameter -pub fn loadCodepoints(text: [*:0]const u8) RaylibError![]i32 { +pub fn loadCodepoints(text: [:0]const u8) RaylibError![]i32 { if (@sizeOf(c_int) != @sizeOf(i32)) { @compileError("Can't cast pointer to c_int array to i32 because they don't have the same size"); } @@ -2289,7 +2289,7 @@ pub fn loadCodepoints(text: [*:0]const u8) RaylibError![]i32 { } /// Text formatting with variables (sprintf() style) -pub fn textFormat(text: [*:0]const u8, args: anytype) [*:0]const u8 { +pub fn textFormat(text: [:0]const u8, args: anytype) [:0]const u8 { comptime { const info = @typeInfo(@TypeOf(args)); switch (info) { @@ -2307,7 +2307,7 @@ pub fn textFormat(text: [*:0]const u8, args: anytype) [*:0]const u8 { } /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) -pub fn traceLog(logLevel: TraceLogLevel, text: [*:0]const u8, args: anytype) void { +pub fn traceLog(logLevel: TraceLogLevel, text: [:0]const u8, args: anytype) void { comptime { const info = @typeInfo(@TypeOf(args)); switch (info) { @@ -2325,10 +2325,10 @@ pub fn traceLog(logLevel: TraceLogLevel, text: [*:0]const u8, args: anytype) voi } /// Split text into multiple strings -pub fn textSplit(text: [*:0]const u8, delimiter: u8) [][*:0]const u8 { +pub fn textSplit(text: [:0]const u8, delimiter: u8) [][:0]const u8 { var count: i32 = 0; - var res: [][*:0]const u8 = undefined; - res.ptr = @as([*][*:0]const u8, @ptrCast(cdef.TextSplit(@as([*c]const u8, @ptrCast(text)), delimiter, @as([*c]c_int, @ptrCast(&count))))); + var res: [][:0]const u8 = undefined; + res.ptr = @as([*][:0]const u8, @ptrCast(cdef.TextSplit(@as([*c]const u8, @ptrCast(text)), delimiter, @as([*c]c_int, @ptrCast(&count))))); res.len = @as(usize, @intCast(count)); return res; } @@ -2346,7 +2346,7 @@ pub fn loadMaterialDefault() RaylibError!Material { } /// Load materials from model file -pub fn loadMaterials(fileName: [*:0]const u8) RaylibError![]Material { +pub fn loadMaterials(fileName: [:0]const u8) RaylibError![]Material { var materialCount: i32 = 0; var res: []Material = undefined; @@ -2365,7 +2365,7 @@ pub fn loadMaterials(fileName: [*:0]const u8) RaylibError![]Material { } /// Load model from files (meshes and materials) -pub fn loadModel(fileName: [*:0]const u8) RaylibError!Model { +pub fn loadModel(fileName: [:0]const u8) RaylibError!Model { const model = cdef.LoadModel(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsModelValid(model); return if (isValid) model else RaylibError.LoadModel; @@ -2379,7 +2379,7 @@ pub fn loadModelFromMesh(mesh: Mesh) RaylibError!Model { } /// Load model animations from file -pub fn loadModelAnimations(fileName: [*:0]const u8) RaylibError![]ModelAnimation { +pub fn loadModelAnimations(fileName: [:0]const u8) RaylibError![]ModelAnimation { var animCount: i32 = 0; var res: []ModelAnimation = undefined; @@ -2397,21 +2397,21 @@ pub fn unloadModelAnimations(animations: []ModelAnimation) void { } /// Load sound from file -pub fn loadSound(fileName: [*:0]const u8) RaylibError!Sound { +pub fn loadSound(fileName: [:0]const u8) RaylibError!Sound { const sound = cdef.LoadSound(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsSoundValid(sound); return if (isValid) sound else RaylibError.LoadSound; } /// Load wave data from file -pub fn loadWave(fileName: [*:0]const u8) RaylibError!Wave { +pub fn loadWave(fileName: [:0]const u8) RaylibError!Wave { const wave = cdef.LoadWave(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsWaveValid(wave); return if (isValid) wave else RaylibError.LoadWave; } /// Load wave from memory buffer, fileType refers to extension: i.e. '.wav' -pub fn loadWaveFromMemory(fileType: [*:0]const u8, fileData: []const u8) RaylibError!Wave { +pub fn loadWaveFromMemory(fileType: [:0]const u8, fileData: []const u8) RaylibError!Wave { const wave = cdef.LoadWaveFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len))); const isValid = cdef.IsWaveValid(wave); return if (isValid) wave else RaylibError.LoadWave; @@ -2426,14 +2426,14 @@ pub fn loadWaveSamples(wave: Wave) []f32 { } /// Load music stream from file -pub fn loadMusicStream(fileName: [*:0]const u8) RaylibError!Music { +pub fn loadMusicStream(fileName: [:0]const u8) RaylibError!Music { const music = cdef.LoadMusicStream(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsMusicValid(music); return if (isValid) music else RaylibError.LoadMusic; } /// Load music stream from data -pub fn loadMusicStreamFromMemory(fileType: [*:0]const u8, data: []const u8) RaylibError!Music { +pub fn loadMusicStreamFromMemory(fileType: [:0]const u8, data: []const u8) RaylibError!Music { const music = cdef.LoadMusicStreamFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len))); const isValid = cdef.IsMusicValid(music); return if (isValid) music else RaylibError.LoadMusic; @@ -2513,12 +2513,12 @@ pub fn drawTextCodepoints(font: Font, codepoints: []const c_int, position: Vecto } /// Load UTF-8 text encoded from codepoints array -pub fn loadUTF8(codepoints: []const c_int) [*:0]u8 { +pub fn loadUTF8(codepoints: []const c_int) [:0]u8 { return std.mem.span(cdef.LoadUTF8(@as([*c]const c_int, @ptrCast(codepoints)), @as(c_int, @intCast(codepoints.len)))); } /// Join text strings with delimiter -pub fn textJoin(textList: [][*:0]const u8, delimiter: [*:0]const u8) [*:0]const u8 { +pub fn textJoin(textList: [][:0]const u8, delimiter: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.TextJoin(@as([*c][*c]const u8, @ptrCast(textList)), @as(c_int, @intCast(textList.len)), @as([*c]const u8, @ptrCast(delimiter)))); } diff --git a/lib/raygui.zig b/lib/raygui.zig index bc5b657..23ecd8e 100644 --- a/lib/raygui.zig +++ b/lib/raygui.zig @@ -549,7 +549,7 @@ pub fn guiGetFont() Font { } /// 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))); } @@ -569,12 +569,12 @@ pub fn guiDisableTooltip() void { } /// 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))); } /// 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)))); } @@ -589,156 +589,156 @@ pub fn guiDrawIcon(iconId: i32, posX: i32, posY: i32, pixelSize: i32, color: Col } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)); } /// 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)); } /// 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)); } /// 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)); } /// 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)); } /// 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)); } /// 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)); } /// 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)); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } /// 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)))); } diff --git a/lib/raylib.zig b/lib/raylib.zig index aa98247..8b36999 100644 --- a/lib/raylib.zig +++ b/lib/raylib.zig @@ -850,17 +850,17 @@ pub const Image = extern struct { format: PixelFormat, /// Load image from file into CPU memory (RAM) - pub fn init(fileName: [*:0]const u8) RaylibError!Image { + pub fn init(fileName: [:0]const u8) RaylibError!Image { return rl.loadImage(fileName); } /// Load image from RAW file data - pub fn initRaw(fileName: [*:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) RaylibError!Image { + pub fn initRaw(fileName: [:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) RaylibError!Image { return rl.loadImageRaw(fileName, width, height, format, headerSize); } /// Load image sequence from file (frames appended to image.data) - pub fn initAnim(fileName: [*:0]const u8, frames: *i32) RaylibError!Image { + pub fn initAnim(fileName: [:0]const u8, frames: *i32) RaylibError!Image { return rl.loadImageAnim(fileName, frames); } @@ -880,12 +880,12 @@ pub const Image = extern struct { } /// Create an image from text (default font) - pub fn initText(text: [*:0]const u8, fontSize: i32, color: Color) RaylibError!Image { + pub fn initText(text: [:0]const u8, fontSize: i32, color: Color) RaylibError!Image { return rl.imageText(text, fontSize, color); } /// Create an image from text (custom sprite font) - pub fn initTextEx(font: Font, text: [*:0]const u8, fontSize: f32, spacing: f32, t: Color) RaylibError!Image { + pub fn initTextEx(font: Font, text: [:0]const u8, fontSize: f32, spacing: f32, t: Color) RaylibError!Image { return rl.imageTextEx(font, text, fontSize, spacing, t); } @@ -930,7 +930,7 @@ pub const Image = extern struct { } /// Generate image: grayscale image from text data - pub fn genText(width: i32, height: i32, text: [*:0]const u8) Image { + pub fn genText(width: i32, height: i32, text: [:0]const u8) Image { return rl.genImageText(width, height, text); } @@ -1145,22 +1145,22 @@ pub const Image = extern struct { } /// Draw text (using default font) within an image (destination) - pub fn drawText(self: *Image, text: [*:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void { + pub fn drawText(self: *Image, text: [:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void { rl.imageDrawText(self, text, posX, posY, fontSize, color); } /// Draw text (custom sprite font) within an image (destination) - pub fn drawTextEx(self: *Image, font: Font, text: [*:0]const u8, position: Vector2, fontSize: f32, spacing: f32, t: Color) void { + pub fn drawTextEx(self: *Image, font: Font, text: [:0]const u8, position: Vector2, fontSize: f32, spacing: f32, t: Color) void { rl.imageDrawTextEx(self, font, text, position, fontSize, spacing, t); } /// Export image data to file, returns true on success - pub fn exportToFile(self: Image, fileName: [*:0]const u8) bool { + pub fn exportToFile(self: Image, fileName: [:0]const u8) bool { return rl.exportImage(self, fileName); } /// Export image as code file defining an array of bytes, returns true on success - pub fn exportAsCode(self: Image, fileName: [*:0]const u8) bool { + pub fn exportAsCode(self: Image, fileName: [:0]const u8) bool { return rl.exportImageAsCode(self, fileName); } @@ -1186,7 +1186,7 @@ pub const Texture = extern struct { mipmaps: c_int, format: PixelFormat, - pub fn init(fileName: [*:0]const u8) RaylibError!Texture { + pub fn init(fileName: [:0]const u8) RaylibError!Texture { return rl.loadTexture(fileName); } @@ -1290,12 +1290,12 @@ pub const Font = extern struct { glyphs: [*c]GlyphInfo, /// Load font from file into GPU memory (VRAM) - pub fn init(fileName: [*:0]const u8) RaylibError!Font { + pub fn init(fileName: [:0]const u8) RaylibError!Font { return rl.loadFont(fileName); } /// Load font from file with extended parameters, use null for fontChars to load the default character set - pub fn initEx(fileName: [*:0]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { + pub fn initEx(fileName: [:0]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { return rl.loadFontEx(fileName, fontSize, fontChars); } @@ -1305,7 +1305,7 @@ pub const Font = extern struct { } /// Load font from memory buffer, fileType refers to extension: i.e. '.ttf' - pub fn fromMemory(fileType: [*:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { + pub fn fromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { return rl.loadFontFromMemory(fileType, fileData, fontSize, fontChars); } @@ -1320,7 +1320,7 @@ pub const Font = extern struct { } /// Export font as code file, returns true on success - pub fn exportAsCode(self: Font, fileName: [*:0]const u8) bool { + pub fn exportAsCode(self: Font, fileName: [:0]const u8) bool { return rl.exportFontAsCode(self, fileName); } }; @@ -1456,7 +1456,7 @@ pub const Model = extern struct { bindPose: [*c]Transform, /// Load model from file (meshes and materials) - pub fn init(fileName: [*:0]const u8) RaylibError!Model { + pub fn init(fileName: [:0]const u8) RaylibError!Model { return rl.loadModel(fileName); } @@ -1992,7 +1992,7 @@ pub fn setWindowIcons(images: []Image) void { } /// Load shader from files and bind default locations -pub fn loadShader(vsFileName: ?[*:0]const u8, fsFileName: ?[*:0]const u8) RaylibError!Shader { +pub fn loadShader(vsFileName: ?[:0]const u8, fsFileName: ?[:0]const u8) RaylibError!Shader { var vsFileNameFinal = @as([*c]const u8, 0); var fsFileNameFinal = @as([*c]const u8, 0); if (vsFileName) |vsFileNameSure| { @@ -2007,7 +2007,7 @@ pub fn loadShader(vsFileName: ?[*:0]const u8, fsFileName: ?[*:0]const u8) Raylib } /// Load shader from code strings and bind default locations -pub fn loadShaderFromMemory(vsCode: ?[*:0]const u8, fsCode: ?[*:0]const u8) RaylibError!Shader { +pub fn loadShaderFromMemory(vsCode: ?[:0]const u8, fsCode: ?[:0]const u8) RaylibError!Shader { var vsCodeFinal = @as([*c]const u8, 0); var fsCodeFinal = @as([*c]const u8, 0); if (vsCode) |vsCodeSure| { @@ -2022,7 +2022,7 @@ pub fn loadShaderFromMemory(vsCode: ?[*:0]const u8, fsCode: ?[*:0]const u8) Rayl } /// Load file data as byte array (read) -pub fn loadFileData(fileName: [*:0]const u8) RaylibError![]u8 { +pub fn loadFileData(fileName: [:0]const u8) RaylibError![]u8 { var bytesRead: i32 = 0; var res: []u8 = undefined; @@ -2035,12 +2035,12 @@ pub fn loadFileData(fileName: [*:0]const u8) RaylibError![]u8 { } /// Save data to file from byte array (write), returns true on success -pub fn saveFileData(fileName: [*:0]const u8, data: []u8) bool { +pub fn saveFileData(fileName: [:0]const u8, data: []u8) bool { return cdef.SaveFileData(@as([*c]const u8, @ptrCast(fileName)), @as(*anyopaque, @ptrCast(data.ptr)), @as(c_int, @intCast(data.len))); } /// Export data to code (.h), returns true on success -pub fn exportDataAsCode(data: []const u8, fileName: [*:0]const u8) bool { +pub fn exportDataAsCode(data: []const u8, fileName: [:0]const u8) bool { return cdef.ExportDataAsCode(@as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len)), @as([*c]const u8, @ptrCast(fileName))); } @@ -2095,21 +2095,21 @@ pub fn computeSHA1(data: []u8) [5]u32 { } /// Load image from file into CPU memory (RAM) -pub fn loadImage(fileName: [*:0]const u8) RaylibError!Image { +pub fn loadImage(fileName: [:0]const u8) RaylibError!Image { const image = cdef.LoadImage(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; } /// Load image from RAW file data -pub fn loadImageRaw(fileName: [*:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) RaylibError!Image { +pub fn loadImageRaw(fileName: [:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) RaylibError!Image { const image = cdef.LoadImageRaw(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, width), @as(c_int, height), format, @as(c_int, headerSize)); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; } /// Load image sequence from file (frames appended to image.data) -pub fn loadImageAnim(fileName: [*:0]const u8, frames: *i32) RaylibError!Image { +pub fn loadImageAnim(fileName: [:0]const u8, frames: *i32) RaylibError!Image { const image = cdef.LoadImageAnim(@as([*c]const u8, @ptrCast(fileName)), @as([*c]c_int, @ptrCast(frames))); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; @@ -2129,21 +2129,21 @@ pub fn loadImageFromScreen() RaylibError!Image { return if (isValid) image else RaylibError.LoadImage; } -pub fn loadImageAnimFromMemory(fileType: [*:0]const u8, fileData: []const u8, frames: *i32) RaylibError!Image { +pub fn loadImageAnimFromMemory(fileType: [:0]const u8, fileData: []const u8, frames: *i32) RaylibError!Image { const image = cdef.LoadImageAnimFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len)), @as([*c]c_int, @ptrCast(frames))); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; } /// Load image from memory buffer, fileType refers to extension: i.e. '.png' -pub fn loadImageFromMemory(fileType: [*:0]const u8, fileData: []const u8) RaylibError!Image { +pub fn loadImageFromMemory(fileType: [:0]const u8, fileData: []const u8) RaylibError!Image { const image = cdef.LoadImageFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len))); const isValid = cdef.IsImageValid(image); return if (isValid) image else RaylibError.LoadImage; } /// Create an image from text (default font) -pub fn imageText(text: [*:0]const u8, fontSize: i32, color: Color) RaylibError!Image { +pub fn imageText(text: [:0]const u8, fontSize: i32, color: Color) RaylibError!Image { // TODO: ImageText requires SUPPORT_MODULE_RTEXT. Error out if not loaded. const image = cdef.ImageText(@as([*c]const u8, @ptrCast(text)), @as(c_int, fontSize), color); const isValid = cdef.IsImageValid(image); @@ -2151,7 +2151,7 @@ pub fn imageText(text: [*:0]const u8, fontSize: i32, color: Color) RaylibError!I } /// Create an image from text (custom sprite font) -pub fn imageTextEx(font: Font, text: [*:0]const u8, fontSize: f32, spacing: f32, tint: Color) RaylibError!Image { +pub fn imageTextEx(font: Font, text: [:0]const u8, fontSize: f32, spacing: f32, tint: Color) RaylibError!Image { // TODO: ImageTextEx requires SUPPORT_MODULE_RTEXT. Error out if not loaded. const image = cdef.ImageTextEx(font, @as([*c]const u8, @ptrCast(text)), fontSize, spacing, tint); const isValid = cdef.IsImageValid(image); @@ -2184,7 +2184,7 @@ pub fn loadImagePalette(image: Image, maxPaletteSize: i32) RaylibError![]Color { } /// Load texture from file into GPU memory (VRAM) -pub fn loadTexture(fileName: [*:0]const u8) RaylibError!Texture2D { +pub fn loadTexture(fileName: [:0]const u8) RaylibError!Texture2D { const texture = cdef.LoadTexture(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsTextureValid(texture); return if (isValid) texture else RaylibError.LoadTexture; @@ -2220,14 +2220,14 @@ pub fn getFontDefault() RaylibError!Font { } /// Load font from file into GPU memory (VRAM) -pub fn loadFont(fileName: [*:0]const u8) RaylibError!Font { +pub fn loadFont(fileName: [:0]const u8) RaylibError!Font { const font = cdef.LoadFont(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsFontValid(font); return if (isValid) font else RaylibError.LoadFont; } /// Load font from file with extended parameters, use null for fontChars to load the default character set -pub fn loadFontEx(fileName: [*:0]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { +pub fn loadFontEx(fileName: [:0]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { var fontCharsFinal = @as([*c]c_int, 0); var fontCharsLen: c_int = @as(c_int, 0); if (fontChars) |fontCharsSure| { @@ -2240,7 +2240,7 @@ pub fn loadFontEx(fileName: [*:0]const u8, fontSize: i32, fontChars: ?[]i32) Ray } /// Load font from memory buffer, fileType refers to extension: i.e. '.ttf' -pub fn loadFontFromMemory(fileType: [*:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { +pub fn loadFontFromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) RaylibError!Font { var fileDataFinal = @as([*c]const u8, 0); var fileDataLen: i32 = 0; if (fileData) |fileDataSure| { @@ -2273,7 +2273,7 @@ pub fn loadFontData(fileData: []const u8, fontSize: i32, fontChars: []i32, ty: F } /// Load all codepoints from a UTF-8 text string, codepoints count returned by parameter -pub fn loadCodepoints(text: [*:0]const u8) RaylibError![]i32 { +pub fn loadCodepoints(text: [:0]const u8) RaylibError![]i32 { if (@sizeOf(c_int) != @sizeOf(i32)) { @compileError("Can't cast pointer to c_int array to i32 because they don't have the same size"); } @@ -2289,7 +2289,7 @@ pub fn loadCodepoints(text: [*:0]const u8) RaylibError![]i32 { } /// Text formatting with variables (sprintf() style) -pub fn textFormat(text: [*:0]const u8, args: anytype) [*:0]const u8 { +pub fn textFormat(text: [:0]const u8, args: anytype) [:0]const u8 { comptime { const info = @typeInfo(@TypeOf(args)); switch (info) { @@ -2307,7 +2307,7 @@ pub fn textFormat(text: [*:0]const u8, args: anytype) [*:0]const u8 { } /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) -pub fn traceLog(logLevel: TraceLogLevel, text: [*:0]const u8, args: anytype) void { +pub fn traceLog(logLevel: TraceLogLevel, text: [:0]const u8, args: anytype) void { comptime { const info = @typeInfo(@TypeOf(args)); switch (info) { @@ -2325,10 +2325,10 @@ pub fn traceLog(logLevel: TraceLogLevel, text: [*:0]const u8, args: anytype) voi } /// Split text into multiple strings -pub fn textSplit(text: [*:0]const u8, delimiter: u8) [][*:0]const u8 { +pub fn textSplit(text: [:0]const u8, delimiter: u8) [][:0]const u8 { var count: i32 = 0; - var res: [][*:0]const u8 = undefined; - res.ptr = @as([*][*:0]const u8, @ptrCast(cdef.TextSplit(@as([*c]const u8, @ptrCast(text)), delimiter, @as([*c]c_int, @ptrCast(&count))))); + var res: [][:0]const u8 = undefined; + res.ptr = @as([*][:0]const u8, @ptrCast(cdef.TextSplit(@as([*c]const u8, @ptrCast(text)), delimiter, @as([*c]c_int, @ptrCast(&count))))); res.len = @as(usize, @intCast(count)); return res; } @@ -2346,7 +2346,7 @@ pub fn loadMaterialDefault() RaylibError!Material { } /// Load materials from model file -pub fn loadMaterials(fileName: [*:0]const u8) RaylibError![]Material { +pub fn loadMaterials(fileName: [:0]const u8) RaylibError![]Material { var materialCount: i32 = 0; var res: []Material = undefined; @@ -2365,7 +2365,7 @@ pub fn loadMaterials(fileName: [*:0]const u8) RaylibError![]Material { } /// Load model from files (meshes and materials) -pub fn loadModel(fileName: [*:0]const u8) RaylibError!Model { +pub fn loadModel(fileName: [:0]const u8) RaylibError!Model { const model = cdef.LoadModel(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsModelValid(model); return if (isValid) model else RaylibError.LoadModel; @@ -2379,7 +2379,7 @@ pub fn loadModelFromMesh(mesh: Mesh) RaylibError!Model { } /// Load model animations from file -pub fn loadModelAnimations(fileName: [*:0]const u8) RaylibError![]ModelAnimation { +pub fn loadModelAnimations(fileName: [:0]const u8) RaylibError![]ModelAnimation { var animCount: i32 = 0; var res: []ModelAnimation = undefined; @@ -2397,21 +2397,21 @@ pub fn unloadModelAnimations(animations: []ModelAnimation) void { } /// Load sound from file -pub fn loadSound(fileName: [*:0]const u8) RaylibError!Sound { +pub fn loadSound(fileName: [:0]const u8) RaylibError!Sound { const sound = cdef.LoadSound(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsSoundValid(sound); return if (isValid) sound else RaylibError.LoadSound; } /// Load wave data from file -pub fn loadWave(fileName: [*:0]const u8) RaylibError!Wave { +pub fn loadWave(fileName: [:0]const u8) RaylibError!Wave { const wave = cdef.LoadWave(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsWaveValid(wave); return if (isValid) wave else RaylibError.LoadWave; } /// Load wave from memory buffer, fileType refers to extension: i.e. '.wav' -pub fn loadWaveFromMemory(fileType: [*:0]const u8, fileData: []const u8) RaylibError!Wave { +pub fn loadWaveFromMemory(fileType: [:0]const u8, fileData: []const u8) RaylibError!Wave { const wave = cdef.LoadWaveFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len))); const isValid = cdef.IsWaveValid(wave); return if (isValid) wave else RaylibError.LoadWave; @@ -2426,14 +2426,14 @@ pub fn loadWaveSamples(wave: Wave) []f32 { } /// Load music stream from file -pub fn loadMusicStream(fileName: [*:0]const u8) RaylibError!Music { +pub fn loadMusicStream(fileName: [:0]const u8) RaylibError!Music { const music = cdef.LoadMusicStream(@as([*c]const u8, @ptrCast(fileName))); const isValid = cdef.IsMusicValid(music); return if (isValid) music else RaylibError.LoadMusic; } /// Load music stream from data -pub fn loadMusicStreamFromMemory(fileType: [*:0]const u8, data: []const u8) RaylibError!Music { +pub fn loadMusicStreamFromMemory(fileType: [:0]const u8, data: []const u8) RaylibError!Music { const music = cdef.LoadMusicStreamFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len))); const isValid = cdef.IsMusicValid(music); return if (isValid) music else RaylibError.LoadMusic; @@ -2518,7 +2518,7 @@ pub fn loadUTF8(codepoints: []const c_int) [*:0]u8 { } /// Join text strings with delimiter -pub fn textJoin(textList: [][*:0]const u8, delimiter: [*:0]const u8) [*:0]const u8 { +pub fn textJoin(textList: [][:0]const u8, delimiter: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.TextJoin(@as([*c][*c]const u8, @ptrCast(textList)), @as(c_int, @intCast(textList.len)), @as([*c]const u8, @ptrCast(delimiter)))); } @@ -2554,7 +2554,7 @@ pub const mem = std.mem.Allocator{ }; /// Initialize window and OpenGL context -pub fn initWindow(width: i32, height: i32, title: [*:0]const u8) void { +pub fn initWindow(width: i32, height: i32, title: [:0]const u8) void { cdef.InitWindow(@as(c_int, width), @as(c_int, height), @as([*c]const u8, @ptrCast(title))); } @@ -2649,7 +2649,7 @@ pub fn setWindowIcon(image: Image) void { } /// Set title for window -pub fn setWindowTitle(title: [*:0]const u8) void { +pub fn setWindowTitle(title: [:0]const u8) void { cdef.SetWindowTitle(@as([*c]const u8, @ptrCast(title))); } @@ -2764,17 +2764,17 @@ pub fn getWindowScaleDPI() Vector2 { } /// Get the human-readable, UTF-8 encoded name of the specified monitor -pub fn getMonitorName(monitor: i32) [*:0]const u8 { +pub fn getMonitorName(monitor: i32) [:0]const u8 { return std.mem.span(cdef.GetMonitorName(@as(c_int, monitor))); } /// Set clipboard text content -pub fn setClipboardText(text: [*:0]const u8) void { +pub fn setClipboardText(text: [:0]const u8) void { cdef.SetClipboardText(@as([*c]const u8, @ptrCast(text))); } /// Get clipboard text content -pub fn getClipboardText() [*:0]const u8 { +pub fn getClipboardText() [:0]const u8 { return std.mem.span(cdef.GetClipboardText()); } @@ -2924,12 +2924,12 @@ pub fn isShaderValid(shader: Shader) bool { } /// Get shader uniform location -pub fn getShaderLocation(shader: Shader, uniformName: [*:0]const u8) i32 { +pub fn getShaderLocation(shader: Shader, uniformName: [:0]const u8) i32 { return @as(i32, cdef.GetShaderLocation(shader, @as([*c]const u8, @ptrCast(uniformName)))); } /// Get shader attribute location -pub fn getShaderLocationAttrib(shader: Shader, attribName: [*:0]const u8) i32 { +pub fn getShaderLocationAttrib(shader: Shader, attribName: [:0]const u8) i32 { return @as(i32, cdef.GetShaderLocationAttrib(shader, @as([*c]const u8, @ptrCast(attribName)))); } @@ -3049,7 +3049,7 @@ pub fn unloadRandomSequence(sequence: []i32) void { } /// Takes a screenshot of current screen (filename extension defines format) -pub fn takeScreenshot(fileName: [*:0]const u8) void { +pub fn takeScreenshot(fileName: [:0]const u8) void { cdef.TakeScreenshot(@as([*c]const u8, @ptrCast(fileName))); } @@ -3059,7 +3059,7 @@ pub fn setConfigFlags(flags: ConfigFlags) void { } /// Open URL with default system browser (if available) -pub fn openURL(url: [*:0]const u8) void { +pub fn openURL(url: [:0]const u8) void { cdef.OpenURL(@as([*c]const u8, @ptrCast(url))); } @@ -3109,102 +3109,102 @@ pub fn unloadFileData(data: []u8) void { } /// Load text data from file (read), returns a '\0' terminated string -pub fn loadFileText(fileName: [*:0]const u8) [*:0]u8 { +pub fn loadFileText(fileName: [:0]const u8) [:0]u8 { return std.mem.span(cdef.LoadFileText(@as([*c]const u8, @ptrCast(fileName)))); } /// Unload file text data allocated by LoadFileText() -pub fn unloadFileText(text: [*:0]u8) void { +pub fn unloadFileText(text: [:0]u8) void { cdef.UnloadFileText(@as([*c]u8, @ptrCast(text))); } /// Save text data to file (write), string must be '\0' terminated, returns true on success -pub fn saveFileText(fileName: [*:0]const u8, text: [*:0]u8) bool { +pub fn saveFileText(fileName: [:0]const u8, text: [:0]u8) bool { return cdef.SaveFileText(@as([*c]const u8, @ptrCast(fileName)), @as([*c]u8, @ptrCast(text))); } /// Check if file exists -pub fn fileExists(fileName: [*:0]const u8) bool { +pub fn fileExists(fileName: [:0]const u8) bool { return cdef.FileExists(@as([*c]const u8, @ptrCast(fileName))); } /// Check if a directory path exists -pub fn directoryExists(dirPath: [*:0]const u8) bool { +pub fn directoryExists(dirPath: [:0]const u8) bool { return cdef.DirectoryExists(@as([*c]const u8, @ptrCast(dirPath))); } /// Check file extension (including point: .png, .wav) -pub fn isFileExtension(fileName: [*:0]const u8, ext: [*:0]const u8) bool { +pub fn isFileExtension(fileName: [:0]const u8, ext: [:0]const u8) bool { return cdef.IsFileExtension(@as([*c]const u8, @ptrCast(fileName)), @as([*c]const u8, @ptrCast(ext))); } /// Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) -pub fn getFileLength(fileName: [*:0]const u8) i32 { +pub fn getFileLength(fileName: [:0]const u8) i32 { return @as(i32, cdef.GetFileLength(@as([*c]const u8, @ptrCast(fileName)))); } /// Get pointer to extension for a filename string (includes dot: '.png') -pub fn getFileExtension(fileName: [*:0]const u8) [*:0]const u8 { +pub fn getFileExtension(fileName: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.GetFileExtension(@as([*c]const u8, @ptrCast(fileName)))); } /// Get pointer to filename for a path string -pub fn getFileName(filePath: [*:0]const u8) [*:0]const u8 { +pub fn getFileName(filePath: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.GetFileName(@as([*c]const u8, @ptrCast(filePath)))); } /// Get filename string without extension (uses static string) -pub fn getFileNameWithoutExt(filePath: [*:0]const u8) [*:0]const u8 { +pub fn getFileNameWithoutExt(filePath: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.GetFileNameWithoutExt(@as([*c]const u8, @ptrCast(filePath)))); } /// Get full path for a given fileName with path (uses static string) -pub fn getDirectoryPath(filePath: [*:0]const u8) [*:0]const u8 { +pub fn getDirectoryPath(filePath: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.GetDirectoryPath(@as([*c]const u8, @ptrCast(filePath)))); } /// Get previous directory path for a given path (uses static string) -pub fn getPrevDirectoryPath(dirPath: [*:0]const u8) [*:0]const u8 { +pub fn getPrevDirectoryPath(dirPath: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.GetPrevDirectoryPath(@as([*c]const u8, @ptrCast(dirPath)))); } /// Get current working directory (uses static string) -pub fn getWorkingDirectory() [*:0]const u8 { +pub fn getWorkingDirectory() [:0]const u8 { return std.mem.span(cdef.GetWorkingDirectory()); } /// Get the directory of the running application (uses static string) -pub fn getApplicationDirectory() [*:0]const u8 { +pub fn getApplicationDirectory() [:0]const u8 { return std.mem.span(cdef.GetApplicationDirectory()); } /// Create directories (including full path requested), returns 0 on success -pub fn makeDirectory(dirPath: [*:0]const u8) i32 { +pub fn makeDirectory(dirPath: [:0]const u8) i32 { return @as(i32, cdef.MakeDirectory(@as([*c]const u8, @ptrCast(dirPath)))); } /// Change working directory, return true on success -pub fn changeDirectory(dir: [*:0]const u8) bool { +pub fn changeDirectory(dir: [:0]const u8) bool { return cdef.ChangeDirectory(@as([*c]const u8, @ptrCast(dir))); } /// Check if a given path is a file or a directory -pub fn isPathFile(path: [*:0]const u8) bool { +pub fn isPathFile(path: [:0]const u8) bool { return cdef.IsPathFile(@as([*c]const u8, @ptrCast(path))); } /// Check if fileName is valid for the platform/OS -pub fn isFileNameValid(fileName: [*:0]const u8) bool { +pub fn isFileNameValid(fileName: [:0]const u8) bool { return cdef.IsFileNameValid(@as([*c]const u8, @ptrCast(fileName))); } /// Load directory filepaths -pub fn loadDirectoryFiles(dirPath: [*:0]const u8) FilePathList { +pub fn loadDirectoryFiles(dirPath: [:0]const u8) FilePathList { return cdef.LoadDirectoryFiles(@as([*c]const u8, @ptrCast(dirPath))); } /// Load directory filepaths with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result -pub fn loadDirectoryFilesEx(basePath: [*:0]const u8, filter: [*:0]const u8, scanSubdirs: bool) FilePathList { +pub fn loadDirectoryFilesEx(basePath: [:0]const u8, filter: [:0]const u8, scanSubdirs: bool) FilePathList { return cdef.LoadDirectoryFilesEx(@as([*c]const u8, @ptrCast(basePath)), @as([*c]const u8, @ptrCast(filter)), scanSubdirs); } @@ -3229,12 +3229,12 @@ pub fn unloadDroppedFiles(files: FilePathList) void { } /// Get file modification time (last write time) -pub fn getFileModTime(fileName: [*:0]const u8) i64 { +pub fn getFileModTime(fileName: [:0]const u8) i64 { return @as(i64, cdef.GetFileModTime(@as([*c]const u8, @ptrCast(fileName)))); } /// Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS -pub fn loadAutomationEventList(fileName: [*:0]const u8) AutomationEventList { +pub fn loadAutomationEventList(fileName: [:0]const u8) AutomationEventList { return cdef.LoadAutomationEventList(@as([*c]const u8, @ptrCast(fileName))); } @@ -3244,7 +3244,7 @@ pub fn unloadAutomationEventList(list: AutomationEventList) void { } /// Export automation events list as text file -pub fn exportAutomationEventList(list: AutomationEventList, fileName: [*:0]const u8) bool { +pub fn exportAutomationEventList(list: AutomationEventList, fileName: [:0]const u8) bool { return cdef.ExportAutomationEventList(list, @as([*c]const u8, @ptrCast(fileName))); } @@ -3319,7 +3319,7 @@ pub fn isGamepadAvailable(gamepad: i32) bool { } /// Get gamepad internal name id -pub fn getGamepadName(gamepad: i32) [*:0]const u8 { +pub fn getGamepadName(gamepad: i32) [:0]const u8 { return std.mem.span(cdef.GetGamepadName(@as(c_int, gamepad))); } @@ -3359,7 +3359,7 @@ pub fn getGamepadAxisMovement(gamepad: i32, axis: GamepadAxis) f32 { } /// Set internal gamepad mappings (SDL_GameControllerDB) -pub fn setGamepadMappings(mappings: [*:0]const u8) i32 { +pub fn setGamepadMappings(mappings: [:0]const u8) i32 { return @as(i32, cdef.SetGamepadMappings(@as([*c]const u8, @ptrCast(mappings)))); } @@ -3809,17 +3809,17 @@ pub fn unloadImage(image: Image) void { } /// Export image data to file, returns true on success -pub fn exportImage(image: Image, fileName: [*:0]const u8) bool { +pub fn exportImage(image: Image, fileName: [:0]const u8) bool { return cdef.ExportImage(image, @as([*c]const u8, @ptrCast(fileName))); } /// Export image to memory buffer -pub fn exportImageToMemory(image: Image, fileType: [*:0]const u8, fileSize: *i32) [*:0]u8 { +pub fn exportImageToMemory(image: Image, fileType: [:0]const u8, fileSize: *i32) [:0]u8 { return std.mem.span(cdef.ExportImageToMemory(image, @as([*c]const u8, @ptrCast(fileType)), @as([*c]c_int, @ptrCast(fileSize)))); } /// Export image as code file defining an array of bytes, returns true on success -pub fn exportImageAsCode(image: Image, fileName: [*:0]const u8) bool { +pub fn exportImageAsCode(image: Image, fileName: [:0]const u8) bool { return cdef.ExportImageAsCode(image, @as([*c]const u8, @ptrCast(fileName))); } @@ -3864,7 +3864,7 @@ pub fn genImageCellular(width: i32, height: i32, tileSize: i32) Image { } /// Generate image: grayscale image from text data -pub fn genImageText(width: i32, height: i32, text: [*:0]const u8) Image { +pub fn genImageText(width: i32, height: i32, text: [:0]const u8) Image { return cdef.GenImageText(@as(c_int, width), @as(c_int, height), @as([*c]const u8, @ptrCast(text))); } @@ -4124,12 +4124,12 @@ pub fn imageDraw(dst: *Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, } /// Draw text (using default font) within an image (destination) -pub fn imageDrawText(dst: *Image, text: [*:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void { +pub fn imageDrawText(dst: *Image, text: [:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void { cdef.ImageDrawText(@as([*c]Image, @ptrCast(dst)), @as([*c]const u8, @ptrCast(text)), @as(c_int, posX), @as(c_int, posY), @as(c_int, fontSize), color); } /// Draw text (custom sprite font) within an image (destination) -pub fn imageDrawTextEx(dst: *Image, font: Font, text: [*:0]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void { +pub fn imageDrawTextEx(dst: *Image, font: Font, text: [:0]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void { cdef.ImageDrawTextEx(@as([*c]Image, @ptrCast(dst)), font, @as([*c]const u8, @ptrCast(text)), position, fontSize, spacing, tint); } @@ -4304,7 +4304,7 @@ pub fn unloadFont(font: Font) void { } /// Export font as code file, returns true on success -pub fn exportFontAsCode(font: Font, fileName: [*:0]const u8) bool { +pub fn exportFontAsCode(font: Font, fileName: [:0]const u8) bool { return cdef.ExportFontAsCode(font, @as([*c]const u8, @ptrCast(fileName))); } @@ -4314,17 +4314,17 @@ pub fn drawFPS(posX: i32, posY: i32) void { } /// Draw text (using default font) -pub fn drawText(text: [*:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void { +pub fn drawText(text: [:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void { cdef.DrawText(@as([*c]const u8, @ptrCast(text)), @as(c_int, posX), @as(c_int, posY), @as(c_int, fontSize), color); } /// Draw text using font and additional parameters -pub fn drawTextEx(font: Font, text: [*:0]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void { +pub fn drawTextEx(font: Font, text: [:0]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void { cdef.DrawTextEx(font, @as([*c]const u8, @ptrCast(text)), position, fontSize, spacing, tint); } /// Draw text using Font and pro parameters (rotation) -pub fn drawTextPro(font: Font, text: [*:0]const u8, position: Vector2, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) void { +pub fn drawTextPro(font: Font, text: [:0]const u8, position: Vector2, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) void { cdef.DrawTextPro(font, @as([*c]const u8, @ptrCast(text)), position, origin, rotation, fontSize, spacing, tint); } @@ -4339,12 +4339,12 @@ pub fn setTextLineSpacing(spacing: i32) void { } /// Measure string width for default font -pub fn measureText(text: [*:0]const u8, fontSize: i32) i32 { +pub fn measureText(text: [:0]const u8, fontSize: i32) i32 { return @as(i32, cdef.MeasureText(@as([*c]const u8, @ptrCast(text)), @as(c_int, fontSize))); } /// Measure string size for Font -pub fn measureTextEx(font: Font, text: [*:0]const u8, fontSize: f32, spacing: f32) Vector2 { +pub fn measureTextEx(font: Font, text: [:0]const u8, fontSize: f32, spacing: f32) Vector2 { return cdef.MeasureTextEx(font, @as([*c]const u8, @ptrCast(text)), fontSize, spacing); } @@ -4364,7 +4364,7 @@ pub fn getGlyphAtlasRec(font: Font, codepoint: i32) Rectangle { } /// Unload UTF-8 text encoded from codepoints array -pub fn unloadUTF8(text: [*:0]u8) void { +pub fn unloadUTF8(text: [:0]u8) void { cdef.UnloadUTF8(@as([*c]u8, @ptrCast(text))); } @@ -4374,102 +4374,102 @@ pub fn unloadCodepoints(codepoints: []i32) void { } /// Get total number of codepoints in a UTF-8 encoded string -pub fn getCodepointCount(text: [*:0]const u8) i32 { +pub fn getCodepointCount(text: [:0]const u8) i32 { return @as(i32, cdef.GetCodepointCount(@as([*c]const u8, @ptrCast(text)))); } /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure -pub fn getCodepoint(text: [*:0]const u8, codepointSize: *i32) i32 { +pub fn getCodepoint(text: [:0]const u8, codepointSize: *i32) i32 { return @as(i32, cdef.GetCodepoint(@as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(codepointSize)))); } /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure -pub fn getCodepointNext(text: [*:0]const u8, codepointSize: *i32) i32 { +pub fn getCodepointNext(text: [:0]const u8, codepointSize: *i32) i32 { return @as(i32, cdef.GetCodepointNext(@as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(codepointSize)))); } /// Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure -pub fn getCodepointPrevious(text: [*:0]const u8, codepointSize: *i32) i32 { +pub fn getCodepointPrevious(text: [:0]const u8, codepointSize: *i32) i32 { return @as(i32, cdef.GetCodepointPrevious(@as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(codepointSize)))); } /// Encode one codepoint into UTF-8 byte array (array length returned as parameter) -pub fn codepointToUTF8(codepoint: i32, utf8Size: *i32) [*:0]const u8 { +pub fn codepointToUTF8(codepoint: i32, utf8Size: *i32) [:0]const u8 { return std.mem.span(cdef.CodepointToUTF8(@as(c_int, codepoint), @as([*c]c_int, @ptrCast(utf8Size)))); } /// Copy one string to another, returns bytes copied -pub fn textCopy(dst: *u8, src: [*:0]const u8) i32 { +pub fn textCopy(dst: *u8, src: [:0]const u8) i32 { return @as(i32, cdef.TextCopy(@as([*c]u8, @ptrCast(dst)), @as([*c]const u8, @ptrCast(src)))); } /// Check if two text string are equal -pub fn textIsEqual(text1: [*:0]const u8, text2: [*:0]const u8) bool { +pub fn textIsEqual(text1: [:0]const u8, text2: [:0]const u8) bool { return cdef.TextIsEqual(@as([*c]const u8, @ptrCast(text1)), @as([*c]const u8, @ptrCast(text2))); } /// Get text length, checks for '\0' ending -pub fn textLength(text: [*:0]const u8) u32 { +pub fn textLength(text: [:0]const u8) u32 { return @as(u32, cdef.TextLength(@as([*c]const u8, @ptrCast(text)))); } /// Get a piece of a text string -pub fn textSubtext(text: [*:0]const u8, position: i32, length: i32) [*:0]const u8 { +pub fn textSubtext(text: [:0]const u8, position: i32, length: i32) [:0]const u8 { return std.mem.span(cdef.TextSubtext(@as([*c]const u8, @ptrCast(text)), @as(c_int, position), @as(c_int, length))); } /// Replace text string (WARNING: memory must be freed!) -pub fn textReplace(text: [*:0]const u8, replace: [*:0]const u8, by: [*:0]const u8) [*:0]u8 { +pub fn textReplace(text: [:0]const u8, replace: [:0]const u8, by: [:0]const u8) [:0]u8 { return std.mem.span(cdef.TextReplace(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(replace)), @as([*c]const u8, @ptrCast(by)))); } /// Insert text in a position (WARNING: memory must be freed!) -pub fn textInsert(text: [*:0]const u8, insert: [*:0]const u8, position: i32) [*:0]u8 { +pub fn textInsert(text: [:0]const u8, insert: [:0]const u8, position: i32) [:0]u8 { return std.mem.span(cdef.TextInsert(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(insert)), @as(c_int, position))); } /// Append text at specific position and move cursor! -pub fn textAppend(text: [*:0]u8, append: [*:0]const u8, position: *i32) void { +pub fn textAppend(text: [:0]u8, append: [:0]const u8, position: *i32) void { cdef.TextAppend(@as([*c]u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(append)), @as([*c]c_int, @ptrCast(position))); } /// Find first text occurrence within a string -pub fn textFindIndex(text: [*:0]const u8, find: [*:0]const u8) i32 { +pub fn textFindIndex(text: [:0]const u8, find: [:0]const u8) i32 { return @as(i32, cdef.TextFindIndex(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(find)))); } /// Get upper case version of provided string -pub fn textToUpper(text: [*:0]const u8) [*:0]const u8 { +pub fn textToUpper(text: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.TextToUpper(@as([*c]const u8, @ptrCast(text)))); } /// Get lower case version of provided string -pub fn textToLower(text: [*:0]const u8) [*:0]const u8 { +pub fn textToLower(text: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.TextToLower(@as([*c]const u8, @ptrCast(text)))); } /// Get Pascal case notation version of provided string -pub fn textToPascal(text: [*:0]const u8) [*:0]const u8 { +pub fn textToPascal(text: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.TextToPascal(@as([*c]const u8, @ptrCast(text)))); } /// Get Snake case notation version of provided string -pub fn textToSnake(text: [*:0]const u8) [*:0]const u8 { +pub fn textToSnake(text: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.TextToSnake(@as([*c]const u8, @ptrCast(text)))); } /// Get Camel case notation version of provided string -pub fn textToCamel(text: [*:0]const u8) [*:0]const u8 { +pub fn textToCamel(text: [:0]const u8) [:0]const u8 { return std.mem.span(cdef.TextToCamel(@as([*c]const u8, @ptrCast(text)))); } /// Get integer value from text (negative values not supported) -pub fn textToInteger(text: [*:0]const u8) i32 { +pub fn textToInteger(text: [:0]const u8) i32 { return @as(i32, cdef.TextToInteger(@as([*c]const u8, @ptrCast(text)))); } /// Get float value from text (negative values not supported) -pub fn textToFloat(text: [*:0]const u8) f32 { +pub fn textToFloat(text: [:0]const u8) f32 { return cdef.TextToFloat(@as([*c]const u8, @ptrCast(text))); } @@ -4669,12 +4669,12 @@ pub fn genMeshTangents(mesh: *Mesh) void { } /// Export mesh data to file, returns true on success -pub fn exportMesh(mesh: Mesh, fileName: [*:0]const u8) bool { +pub fn exportMesh(mesh: Mesh, fileName: [:0]const u8) bool { return cdef.ExportMesh(mesh, @as([*c]const u8, @ptrCast(fileName))); } /// Export mesh as code file (.h) defining multiple arrays of vertex attributes -pub fn exportMeshAsCode(mesh: Mesh, fileName: [*:0]const u8) bool { +pub fn exportMeshAsCode(mesh: Mesh, fileName: [:0]const u8) bool { return cdef.ExportMeshAsCode(mesh, @as([*c]const u8, @ptrCast(fileName))); } @@ -4879,12 +4879,12 @@ pub fn unloadSoundAlias(alias: Sound) void { } /// Export wave data to file, returns true on success -pub fn exportWave(wave: Wave, fileName: [*:0]const u8) bool { +pub fn exportWave(wave: Wave, fileName: [:0]const u8) bool { return cdef.ExportWave(wave, @as([*c]const u8, @ptrCast(fileName))); } /// Export wave sample data to code (.h), returns true on success -pub fn exportWaveAsCode(wave: Wave, fileName: [*:0]const u8) bool { +pub fn exportWaveAsCode(wave: Wave, fileName: [:0]const u8) bool { return cdef.ExportWaveAsCode(wave, @as([*c]const u8, @ptrCast(fileName))); } diff --git a/lib/rlgl.zig b/lib/rlgl.zig index c704422..31a0342 100644 --- a/lib/rlgl.zig +++ b/lib/rlgl.zig @@ -836,7 +836,7 @@ pub fn rlGetGlTextureFormats(format: i32, glInternalFormat: *u32, glFormat: *u32 } /// 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))); } @@ -856,7 +856,7 @@ pub fn rlReadTexturePixels(id: u32, width: i32, height: i32, format: i32) *anyop } /// 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))); } @@ -881,12 +881,12 @@ pub fn rlUnloadFramebuffer(id: u32) void { } /// 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)))); } /// 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))); } @@ -901,12 +901,12 @@ pub fn rlUnloadShaderProgram(id: u32) void { } /// 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)))); } /// 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)))); }