Move from sentinel-terminated slices to sentinel-terminated pointers ([:0] -> [*:0])

This commit is contained in:
Not-Nik 2024-07-09 21:59:38 +02:00
parent 19db777449
commit a03b65a76c
Failed to generate hash of commit
6 changed files with 205 additions and 205 deletions

View file

@ -837,17 +837,17 @@ pub const Image = extern struct {
format: PixelFormat,
/// Load image from file into CPU memory (RAM)
pub fn init(fileName: [:0]const u8) Image {
pub fn init(fileName: [*:0]const u8) 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) Image {
pub fn initRaw(fileName: [*:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) 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) Image {
pub fn initAnim(fileName: [*:0]const u8, frames: *i32) Image {
return rl.loadImageAnim(fileName, frames);
}
@ -867,12 +867,12 @@ pub const Image = extern struct {
}
/// Create an image from text (default font)
pub fn initText(text: [:0]const u8, fontSize: i32, color: Color) Image {
pub fn initText(text: [*:0]const u8, fontSize: i32, color: Color) 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) Image {
pub fn initTextEx(font: Font, text: [*:0]const u8, fontSize: f32, spacing: f32, t: Color) Image {
return rl.imageTextEx(font, text, fontSize, spacing, t);
}
@ -917,7 +917,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);
}
@ -1132,22 +1132,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);
}
@ -1173,7 +1173,7 @@ pub const Texture = extern struct {
mipmaps: c_int,
format: PixelFormat,
pub fn init(fileName: [:0]const u8) Texture {
pub fn init(fileName: [*:0]const u8) Texture {
return rl.loadTexture(fileName);
}
@ -1277,12 +1277,12 @@ pub const Font = extern struct {
glyphs: [*c]GlyphInfo,
/// Load font from file into GPU memory (VRAM)
pub fn init(fileName: [:0]const u8) Font {
pub fn init(fileName: [*:0]const u8) Font {
return rl.loadFont(fileName);
}
/// Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set
pub fn initEx(fileName: [:0]const u8, fontSize: i32, fontChars: []i32) Font {
pub fn initEx(fileName: [*:0]const u8, fontSize: i32, fontChars: []i32) Font {
return rl.loadFontEx(fileName, fontSize, fontChars);
}
@ -1292,7 +1292,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) Font {
pub fn fromMemory(fileType: [*:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: []i32) Font {
return rl.loadFontFromMemory(fileType, fileData, fontSize, fontChars);
}
@ -1307,7 +1307,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);
}
};
@ -1441,7 +1441,7 @@ pub const Model = extern struct {
bindPose: [*c]Transform,
/// Load model from file (meshes and materials)
pub fn init(fileName: [:0]const u8) Model {
pub fn init(fileName: [*:0]const u8) Model {
return rl.loadModel(fileName);
}
@ -1977,7 +1977,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) Shader {
pub fn loadShader(vsFileName: ?[*:0]const u8, fsFileName: ?[*:0]const u8) Shader {
var vsFileNameFinal = @as([*c]const u8, 0);
var fsFileNameFinal = @as([*c]const u8, 0);
if (vsFileName) |vsFileNameSure| {
@ -1990,7 +1990,7 @@ pub fn loadShader(vsFileName: ?[:0]const u8, fsFileName: ?[:0]const u8) Shader {
}
/// Load shader from code strings and bind default locations
pub fn loadShaderFromMemory(vsCode: ?[:0]const u8, fsCode: ?[:0]const u8) Shader {
pub fn loadShaderFromMemory(vsCode: ?[*:0]const u8, fsCode: ?[*:0]const u8) Shader {
var vsCodeFinal = @as([*c]const u8, 0);
var fsCodeFinal = @as([*c]const u8, 0);
if (vsCode) |vsCodeSure| {
@ -2003,7 +2003,7 @@ pub fn loadShaderFromMemory(vsCode: ?[:0]const u8, fsCode: ?[:0]const u8) Shader
}
/// 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;
@ -2016,12 +2016,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)));
}
@ -2061,12 +2061,12 @@ pub fn decodeDataBase64(data: []const u8) []u8 {
return res;
}
pub fn loadImageAnimFromMemory(fileType: [:0]const u8, fileData: []const u8, frames: *i32) Image {
pub fn loadImageAnimFromMemory(fileType: [*:0]const u8, fileData: []const u8, frames: *i32) Image {
return 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)));
}
/// Load image from memory buffer, fileType refers to extension: i.e. '.png'
pub fn loadImageFromMemory(fileType: [:0]const u8, fileData: []const u8) Image {
pub fn loadImageFromMemory(fileType: [*:0]const u8, fileData: []const u8) Image {
return cdef.LoadImageFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len)));
}
@ -2097,7 +2097,7 @@ pub fn loadImagePalette(image: Image, maxPaletteSize: i32) RaylibError![]Color {
/// Load font from file with extended parameters, use null for codepoints and 0
/// for codepointCount to load the default character set
pub fn loadFontEx(fileName: [:0]const u8, fontSize: i32, fontChars: ?[]i32) Font {
pub fn loadFontEx(fileName: [*:0]const u8, fontSize: i32, fontChars: ?[]i32) Font {
var fontCharsFinal = @as([*c]c_int, 0);
var fontCharsLen: c_int = @as(c_int, 0);
if (fontChars) |fontCharsSure| {
@ -2108,7 +2108,7 @@ pub fn loadFontEx(fileName: [:0]const u8, fontSize: i32, fontChars: ?[]i32) Font
}
/// 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) Font {
pub fn loadFontFromMemory(fileType: [*:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: []i32) Font {
var fileDataFinal = @as([*c]const u8, 0);
var fileDataLen: i32 = 0;
if (fileData) |fileDataSure| {
@ -2131,7 +2131,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");
}
@ -2147,7 +2147,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) {
@ -2165,10 +2165,10 @@ pub fn textFormat(text: [:0]const u8, args: anytype) [:0]const u8 {
}
/// 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;
}
@ -2179,7 +2179,7 @@ pub fn drawMeshInstanced(mesh: Mesh, material: Material, transforms: []const Mat
}
/// 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;
@ -2192,7 +2192,7 @@ pub fn loadMaterials(fileName: [:0]const u8) RaylibError![]Material {
}
/// 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;
@ -2210,7 +2210,7 @@ pub fn unloadModelAnimations(animations: []ModelAnimation) void {
}
/// Load wave from memory buffer, fileType refers to extension: i.e. '.wav'
pub fn loadWaveFromMemory(fileType: [:0]const u8, fileData: []const u8) Wave {
pub fn loadWaveFromMemory(fileType: [*:0]const u8, fileData: []const u8) Wave {
return cdef.LoadWaveFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len)));
}
@ -2223,7 +2223,7 @@ pub fn loadWaveSamples(wave: Wave) []f32 {
}
/// Load music stream from data
pub fn loadMusicStreamFromMemory(fileType: [:0]const u8, data: []const u8) Music {
pub fn loadMusicStreamFromMemory(fileType: [*:0]const u8, data: []const u8) Music {
return cdef.LoadMusicStreamFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len)));
}
@ -2258,12 +2258,12 @@ pub fn unloadFontData(chars: []GlyphInfo) void {
}
/// 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))));
}
@ -2299,7 +2299,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)));
}
@ -2394,7 +2394,7 @@ pub fn setWindowIcon(image: Image) void {
}
/// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
pub fn setWindowTitle(title: [:0]const u8) void {
pub fn setWindowTitle(title: [*:0]const u8) void {
cdef.SetWindowTitle(@as([*c]const u8, @ptrCast(title)));
}
@ -2509,17 +2509,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());
}
@ -2664,12 +2664,12 @@ pub fn isShaderReady(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))));
}
@ -2789,7 +2789,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)));
}
@ -2799,12 +2799,12 @@ 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)));
}
/// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
pub fn traceLog(logLevel: TraceLogLevel, text: [:0]const u8) void {
pub fn traceLog(logLevel: TraceLogLevel, text: [*:0]const u8) void {
cdef.TraceLog(logLevel, @as([*c]const u8, @ptrCast(text)));
}
@ -2854,97 +2854,97 @@ 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());
}
/// 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
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);
}
@ -2969,12 +2969,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)));
}
@ -2984,7 +2984,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)));
}
@ -3059,7 +3059,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)));
}
@ -3099,7 +3099,7 @@ pub fn getGamepadAxisMovement(gamepad: i32, axis: i32) 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))));
}
@ -3564,22 +3564,22 @@ pub fn getCollisionRec(rec1: Rectangle, rec2: Rectangle) Rectangle {
}
/// Load image from file into CPU memory (RAM)
pub fn loadImage(fileName: [:0]const u8) Image {
pub fn loadImage(fileName: [*:0]const u8) Image {
return cdef.LoadImage(@as([*c]const u8, @ptrCast(fileName)));
}
/// Load image from RAW file data
pub fn loadImageRaw(fileName: [:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) Image {
pub fn loadImageRaw(fileName: [*:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) Image {
return cdef.LoadImageRaw(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, width), @as(c_int, height), format, @as(c_int, headerSize));
}
/// Load image from SVG file data or string with specified size
pub fn loadImageSvg(fileNameOrString: [:0]const u8, width: i32, height: i32) Image {
pub fn loadImageSvg(fileNameOrString: [*:0]const u8, width: i32, height: i32) Image {
return cdef.LoadImageSvg(@as([*c]const u8, @ptrCast(fileNameOrString)), @as(c_int, width), @as(c_int, height));
}
/// Load image sequence from file (frames appended to image.data)
pub fn loadImageAnim(fileName: [:0]const u8, frames: *i32) Image {
pub fn loadImageAnim(fileName: [*:0]const u8, frames: *i32) Image {
return cdef.LoadImageAnim(@as([*c]const u8, @ptrCast(fileName)), @as([*c]c_int, @ptrCast(frames)));
}
@ -3604,17 +3604,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)));
}
@ -3659,7 +3659,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)));
}
@ -3674,12 +3674,12 @@ pub fn imageFromImage(image: Image, rec: Rectangle) Image {
}
/// Create an image from text (default font)
pub fn imageText(text: [:0]const u8, fontSize: i32, color: Color) Image {
pub fn imageText(text: [*:0]const u8, fontSize: i32, color: Color) Image {
return cdef.ImageText(@as([*c]const u8, @ptrCast(text)), @as(c_int, fontSize), color);
}
/// Create an image from text (custom sprite font)
pub fn imageTextEx(font: Font, text: [:0]const u8, fontSize: f32, spacing: f32, tint: Color) Image {
pub fn imageTextEx(font: Font, text: [*:0]const u8, fontSize: f32, spacing: f32, tint: Color) Image {
return cdef.ImageTextEx(font, @as([*c]const u8, @ptrCast(text)), fontSize, spacing, tint);
}
@ -3899,17 +3899,17 @@ 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);
}
/// Load texture from file into GPU memory (VRAM)
pub fn loadTexture(fileName: [:0]const u8) Texture2D {
pub fn loadTexture(fileName: [*:0]const u8) Texture2D {
return cdef.LoadTexture(@as([*c]const u8, @ptrCast(fileName)));
}
@ -4089,7 +4089,7 @@ pub fn getFontDefault() Font {
}
/// Load font from file into GPU memory (VRAM)
pub fn loadFont(fileName: [:0]const u8) Font {
pub fn loadFont(fileName: [*:0]const u8) Font {
return cdef.LoadFont(@as([*c]const u8, @ptrCast(fileName)));
}
@ -4109,7 +4109,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)));
}
@ -4119,17 +4119,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);
}
@ -4144,12 +4144,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);
}
@ -4169,7 +4169,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)));
}
@ -4179,102 +4179,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)));
}
@ -4379,7 +4379,7 @@ pub fn drawGrid(slices: i32, spacing: f32) void {
}
/// Load model from files (meshes and materials)
pub fn loadModel(fileName: [:0]const u8) Model {
pub fn loadModel(fileName: [*:0]const u8) Model {
return cdef.LoadModel(@as([*c]const u8, @ptrCast(fileName)));
}
@ -4474,12 +4474,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)));
}
@ -4644,7 +4644,7 @@ pub fn getMasterVolume() f32 {
}
/// Load wave data from file
pub fn loadWave(fileName: [:0]const u8) Wave {
pub fn loadWave(fileName: [*:0]const u8) Wave {
return cdef.LoadWave(@as([*c]const u8, @ptrCast(fileName)));
}
@ -4654,7 +4654,7 @@ pub fn isWaveReady(wave: Wave) bool {
}
/// Load sound from file
pub fn loadSound(fileName: [:0]const u8) Sound {
pub fn loadSound(fileName: [*:0]const u8) Sound {
return cdef.LoadSound(@as([*c]const u8, @ptrCast(fileName)));
}
@ -4694,12 +4694,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)));
}
@ -4764,7 +4764,7 @@ pub fn unloadWaveSamples(samples: []f32) void {
}
/// Load music stream from file
pub fn loadMusicStream(fileName: [:0]const u8) Music {
pub fn loadMusicStream(fileName: [*:0]const u8) Music {
return cdef.LoadMusicStream(@as([*c]const u8, @ptrCast(fileName)));
}