← ziglang.inraylib-zigGitHub

core

Window, drawing, shaders, timing, files and input. 211 functions, from raylib's rcore.

Window-related functions

rl.isWindowReady

Check if window has been initialized successfully

Zigfn isWindowReady() bool
Cbool IsWindowReady(void);

rl.isWindowFullscreen

Check if window is currently fullscreen

Zigfn isWindowFullscreen() bool
Cbool IsWindowFullscreen(void);

rl.isWindowHidden

Check if window is currently hidden

Zigfn isWindowHidden() bool
Cbool IsWindowHidden(void);

rl.isWindowMinimized

Check if window is currently minimized

Zigfn isWindowMinimized() bool
Cbool IsWindowMinimized(void);

rl.isWindowMaximized

Check if window is currently maximized

Zigfn isWindowMaximized() bool
Cbool IsWindowMaximized(void);

rl.isWindowFocused

Check if window is currently focused

Zigfn isWindowFocused() bool
Cbool IsWindowFocused(void);

rl.isWindowState

Check if one specific window flag is enabled

Zigfn isWindowState(flag: ConfigFlags) bool
Cbool IsWindowState(unsigned int flag);

Used in core_window_flags.

rl.setWindowState

Set window configuration state using flags

Zigfn setWindowState(flags: ConfigFlags) void
Cvoid SetWindowState(unsigned int flags);

Used in core_window_flags.

rl.setWindowIcon

Set icon for window (single image, RGBA 32bit)

Zigfn setWindowIcon(image: Image) void
Cvoid SetWindowIcon(Image image);

rl.setWindowIcons

Set icon for window (multiple images, RGBA 32bit)

Zigfn setWindowIcons(images: []Image) void
Cvoid SetWindowIcons(Image *images, int count);

rl.setWindowTitle

Set title for window

Zigfn setWindowTitle(title: [:0]const u8) void
Cvoid SetWindowTitle(const char *title);

rl.setWindowPosition

Set window position on screen

Zigfn setWindowPosition(x: i32, y: i32) void
Cvoid SetWindowPosition(int x, int y);

rl.setWindowMaxSize

Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)

Zigfn setWindowMaxSize(width: i32, height: i32) void
Cvoid SetWindowMaxSize(int width, int height);

rl.setWindowSize

Set window dimensions

Zigfn setWindowSize(width: i32, height: i32) void
Cvoid SetWindowSize(int width, int height);

rl.setWindowOpacity

Set window opacity [0.0f..1.0f]

Zigfn setWindowOpacity(opacity: f32) void
Cvoid SetWindowOpacity(float opacity);

rl.setWindowFocused

Set window focused

Zigfn setWindowFocused() void
Cvoid SetWindowFocused(void);

rl.getWindowHandle

Get native window handle

Zigfn getWindowHandle() ?*anyopaque
Cvoid *GetWindowHandle(void);

rl.getMonitorName

Get the human-readable, UTF-8 encoded name of the specified monitor

Zigfn getMonitorName(monitor: i32) [:0]const u8
Cconst char *GetMonitorName(int monitor);

Used in core_monitor_detector.

rl.enableEventWaiting

Enable waiting for events on EndDrawing(), no automatic event polling

Zigfn enableEventWaiting() void
Cvoid EnableEventWaiting(void);

rl.disableEventWaiting

Disable waiting for events on EndDrawing(), automatic events polling

Zigfn disableEventWaiting() void
Cvoid DisableEventWaiting(void);

Cursor-related functions

rl.isCursorOnScreen

Check if cursor is on the screen

Zigfn isCursorOnScreen() bool
Cbool IsCursorOnScreen(void);

Drawing-related functions

rl.beginVrStereoMode

Begin stereo rendering (requires VR simulator)

Zigfn beginVrStereoMode(config: VrStereoConfig) void
Cvoid BeginVrStereoMode(VrStereoConfig config);

Used in core_vr_simulator.

VR stereo config functions for VR simulator

rl.loadVrStereoConfig

Load VR stereo config for VR simulator device parameters

Zigfn loadVrStereoConfig(device: VrDeviceInfo) VrStereoConfig
CVrStereoConfig LoadVrStereoConfig(VrDeviceInfo device);

Used in core_vr_simulator.

Shader management functions

rl.loadShaderFromMemory

Load shader from code strings and bind default locations

Zigfn loadShaderFromMemory(vsCode: ?[:0]const u8, fsCode: ?[:0]const u8) error{LoadFailed}!Shader
CShader LoadShaderFromMemory(const char *vsCode, const char *fsCode);

rl.isShaderValid

Check if shader is valid (loaded on GPU)

Zigfn isShaderValid(shader: Shader) bool
Cbool IsShaderValid(Shader shader);

rl.getShaderLocationAttrib

Get shader attribute location

Zigfn getShaderLocationAttrib(shader: Shader, attribName: [:0]const u8) i32
Cint GetShaderLocationAttrib(Shader shader, const char *attribName);

rl.setShaderValue

Set shader uniform value

Set shader uniform value. The GLSL type is inferred from `value`: f32, i32, u32, Vector2/3/4 or [2..4] arrays of f32/i32/u32 (float, vec2.., int, ivec2.., uint, uivec2..). Raw C call: `rl.c.SetShaderValue`.

Zigfn setShaderValue(shader: Shader, locIndex: i32, value: anytype) void
Cvoid SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType);

Used in core_vr_simulator, models_loading_vox, models_skybox_rendering, shaders_ascii_rendering, shaders_basic_lighting, shaders_custom_uniform and 27 more.

rl.setShaderValueV

Set shader uniform value vector

Set shader uniform value array: `values` is a slice (or array pointer) of any type `setShaderValue` accepts; the count is its length.

Zigfn setShaderValueV(shader: Shader, locIndex: i32, values: anytype) void
Cvoid SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count);

Used in shaders_palette_switch, shaders_lights_bloom.

Screen-space-related functions

rl.getScreenToWorldRayEx

Get a ray trace from screen position (i.e mouse) in a viewport

Zigfn getScreenToWorldRayEx(position: Vector2, camera: Camera, width: i32, height: i32) Ray
CRay GetScreenToWorldRayEx(Vector2 position, Camera camera, int width, int height);

rl.getWorldToScreen

Get screen space position for a 3d world space position

Zigfn getWorldToScreen(position: Vector3, camera: Camera) Vector2
CVector2 GetWorldToScreen(Vector3 position, Camera camera);

Used in core_world_screen.

rl.getWorldToScreenEx

Get sized screen space position for a 3d world space position

Zigfn getWorldToScreenEx(position: Vector3, camera: Camera, width: i32, height: i32) Vector2
CVector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height);

rl.getCameraMatrix2D

Get camera 2d transform matrix

Zigfn getCameraMatrix2D(camera: Camera2D) Matrix
CMatrix GetCameraMatrix2D(Camera2D camera);

Timing-related functions

To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL

Random values generation functions

rl.loadRandomSequence

Load random values sequence, no values repeated

Load random values sequence, no values repeated. Free with `unloadRandomSequence`.

Zigfn loadRandomSequence(count: u32, min: i32, max: i32) error{LoadFailed}![]i32
Cint *LoadRandomSequence(unsigned int count, int min, int max);

Used in core_random_sequence.

Misc. functions

rl.openURL

Open URL with default system browser (if available)

Zigfn openURL(url: [:0]const u8) void
Cvoid OpenURL(const char *url);

Logging system

rl.setTraceLogLevel

Set the current threshold (minimum) log level

Zigfn setTraceLogLevel(logLevel: TraceLogLevel) void
Cvoid SetTraceLogLevel(int logLevel);

rl.traceLog

Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)

Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...). Formats with std.fmt; messages longer than 1023 bytes are truncated.

Zigfn traceLog(logLevel: TraceLogLevel, comptime format: []const u8, args: anytype) void
Cvoid TraceLog(int logLevel, const char *text, ...);

Used in core_storage_values, core_automation_events, core_screen_recording, core_keyboard_testbed, shapes_penrose_tile, textures_clipboard_image and 7 more.

rl.setTraceLogCallback

Set custom trace log

Set custom trace log callback. The callback receives each message already formatted (truncated at 1023 bytes); `null` restores raylib's default logger.

Zigfn setTraceLogCallback(comptime callback: ?fn (logLevel: TraceLogLevel, text: [:0]const u8) void) void
Cvoid SetTraceLogCallback(TraceLogCallback callback);

Used in core_custom_logging.

Memory management, using internal allocators

rl.memRealloc

Internal memory reallocator

Internal memory reallocator (`ptr` may be null; `size` is the new size in bytes).

Zigfn memRealloc(ptr: ?*anyopaque, size: u32) ?*anyopaque
Cvoid *MemRealloc(void *ptr, unsigned int size);

File system management functions

rl.loadFileData

Load file data as byte array (read)

Load file data as byte array (read). Free with `unloadFileData`.

Zigfn loadFileData(fileName: [:0]const u8) error{LoadFailed}![]u8
Cunsigned char *LoadFileData(const char *fileName, int *dataSize);

Used in core_storage_values, text_font_sdf.

rl.saveFileData

Save data to file from byte array (write), returns true on success

Save data to file from byte array (write), returns true on success.

Zigfn saveFileData(fileName: [:0]const u8, data: []const u8) bool
Cbool SaveFileData(const char *fileName, const void *data, int dataSize);

Used in core_storage_values, core_screen_recording.

rl.exportDataAsCode

Export data to code (.h), returns true on success

Zigfn exportDataAsCode(data: []const u8, fileName: [:0]const u8) bool
Cbool ExportDataAsCode(const unsigned char *data, int dataSize, const char *fileName);

rl.loadFileText

Load text data from file (read), returns a '\0' terminated string

Load text data from file (read). Free with `unloadFileText`.

Zigfn loadFileText(fileName: [:0]const u8) error{LoadFailed}![:0]u8
Cchar *LoadFileText(const char *fileName);

Used in core_text_file_loading, shaders_rlgl_compute.

rl.saveFileText

Save text data to file (write), string must be '\0' terminated, returns true on success

Save text data to file (write), returns true on success.

Zigfn saveFileText(fileName: [:0]const u8, text: [:0]const u8) bool
Cbool SaveFileText(const char *fileName, const char *text);

File access custom callbacks

rl.setLoadFileDataCallback

Set custom file binary data loader

Set custom file binary data loader (raw C callback).

Zigfn setLoadFileDataCallback(callback: LoadFileDataCallback) void
Cvoid SetLoadFileDataCallback(LoadFileDataCallback callback);

rl.setSaveFileDataCallback

Set custom file binary data saver

Set custom file binary data saver (raw C callback).

Zigfn setSaveFileDataCallback(callback: SaveFileDataCallback) void
Cvoid SetSaveFileDataCallback(SaveFileDataCallback callback);

rl.setLoadFileTextCallback

Set custom file text data loader

Set custom file text data loader (raw C callback).

Zigfn setLoadFileTextCallback(callback: LoadFileTextCallback) void
Cvoid SetLoadFileTextCallback(LoadFileTextCallback callback);

rl.setSaveFileTextCallback

Set custom file text data saver

Set custom file text data saver (raw C callback).

Zigfn setSaveFileTextCallback(callback: SaveFileTextCallback) void
Cvoid SetSaveFileTextCallback(SaveFileTextCallback callback);

rl.fileRename

Rename file (if exists), returns 0 on success

Zigfn fileRename(fileName: [:0]const u8, newFileName: [:0]const u8) i32
Cint FileRename(const char *fileName, const char *fileRename);

rl.fileRemove

Remove file (if exists), returns 0 on success

Zigfn fileRemove(fileName: [:0]const u8) i32
Cint FileRemove(const char *fileName);

rl.fileCopy

Copy file from one path to another, dstPath created if it doesn't exist, returns 0 on success

Zigfn fileCopy(srcPath: [:0]const u8, dstPath: [:0]const u8) i32
Cint FileCopy(const char *srcPath, const char *dstPath);

rl.fileMove

Move file from one directory to another, dstPath created if it doesn't exist, returns 0 on success

Zigfn fileMove(srcPath: [:0]const u8, dstPath: [:0]const u8) i32
Cint FileMove(const char *srcPath, const char *dstPath);

rl.fileTextReplace

Replace text in an existing file, returns 0 on success

Zigfn fileTextReplace(fileName: [:0]const u8, search: [:0]const u8, replacement: [:0]const u8) i32
Cint FileTextReplace(const char *fileName, const char *search, const char *replacement);

rl.fileTextFindIndex

Find text in existing file, returns -1 if index not found or index otherwise

Zigfn fileTextFindIndex(fileName: [:0]const u8, search: [:0]const u8) i32
Cint FileTextFindIndex(const char *fileName, const char *search);

rl.fileExists

Check if file exists

Zigfn fileExists(fileName: [:0]const u8) bool
Cbool FileExists(const char *fileName);

rl.isFileHidden

Check if file path (file or directory) is hidden by OS

Zigfn isFileHidden(filePath: [:0]const u8) bool
Cbool IsFileHidden(const char *filePath);

rl.getFileLength

Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)

Zigfn getFileLength(fileName: [:0]const u8) i32
Cint GetFileLength(const char *fileName);

rl.getFileExtension

Get pointer to extension for a filename string (includes dot: '.png')

Zigfn getFileExtension(fileName: [:0]const u8) [:0]const u8
Cconst char *GetFileExtension(const char *fileName);

rl.getFileNameWithoutExt

Get filename string without extension (uses static string)

Zigfn getFileNameWithoutExt(filePath: [:0]const u8) [:0]const u8
Cconst char *GetFileNameWithoutExt(const char *filePath);

rl.getDirectoryPath

Get full path for a provided fileName with path (uses static string)

Zigfn getDirectoryPath(filePath: [:0]const u8) [:0]const u8
Cconst char *GetDirectoryPath(const char *filePath);

rl.getPrevDirectoryPath

Get previous directory path for a provided path (uses static string)

Zigfn getPrevDirectoryPath(dirPath: [:0]const u8) [:0]const u8
Cconst char *GetPrevDirectoryPath(const char *dirPath);

Used in core_directory_files.

rl.makeDirectory

Create directories (including full path requested), returns 0 on success

Zigfn makeDirectory(dirPath: [:0]const u8) i32
Cint MakeDirectory(const char *dirPath);

rl.changeDirectory

Change working directory, returns 0 on success

Zigfn changeDirectory(dirPath: [:0]const u8) i32
Cint ChangeDirectory(const char *dirPath);

rl.isPathFile

Check if provided path points to a file

Zigfn isPathFile(path: [:0]const u8) bool
Cbool IsPathFile(const char *path);

rl.isPathDirectory

Check if provided path points to a directory

Zigfn isPathDirectory(path: [:0]const u8) bool
Cbool IsPathDirectory(const char *path);

rl.isPathAbsolute

Check if provided path is an absolute path

Zigfn isPathAbsolute(path: [:0]const u8) bool
Cbool IsPathAbsolute(const char *path);

rl.isFileNameValid

Check if fileName is valid for the platform/OS

Zigfn isFileNameValid(fileName: [:0]const u8) bool
Cbool IsFileNameValid(const char *fileName);

rl.loadDirectoryFiles

Load directory filepaths, files and directories, no subdirs scan

Zigfn loadDirectoryFiles(dirPath: [:0]const u8) FilePathList
CFilePathList LoadDirectoryFiles(const char *dirPath);

rl.loadDirectoryFilesEx

Load directory filepaths with extension filtering and subdir scan; some filters available: '*.*','FILES*','DIRS*'

Zigfn loadDirectoryFilesEx(basePath: [:0]const u8, filter: [:0]const u8, scanSubdirs: bool) FilePathList
CFilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs);

Used in core_directory_files.

rl.getDirectoryFileCount

Get the file count in a directory

Zigfn getDirectoryFileCount(dirPath: [:0]const u8) u32
Cunsigned int GetDirectoryFileCount(const char *dirPath);

rl.getDirectoryFileCountEx

Get the file count in a directory with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result

Zigfn getDirectoryFileCountEx(basePath: [:0]const u8, filter: [:0]const u8, scanSubdirs: bool) u32
Cunsigned int GetDirectoryFileCountEx(const char *basePath, const char *filter, bool scanSubdirs);

Compression/Encoding functionality

rl.compressData

Compress data (DEFLATE algorithm), memory must be MemFree()

Compress data (DEFLATE algorithm). Free with `memFree`.

Zigfn compressData(data: []const u8) error{CompressFailed}![]u8
Cunsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize);

rl.decompressData

Decompress data (DEFLATE algorithm), memory must be MemFree()

Decompress data (DEFLATE algorithm). Free with `memFree`.

Zigfn decompressData(compData: []const u8) error{DecompressFailed}![]u8
Cunsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize);

rl.encodeDataBase64

Encode data to Base64 string (includes NULL terminator), memory must be MemFree()

Encode data to Base64 string (includes NULL terminator). Free with `memFree`.

Zigfn encodeDataBase64(data: []const u8) error{EncodeFailed}![:0]u8
Cchar *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize);

Used in core_compute_hash.

rl.decodeDataBase64

Decode Base64 string (expected NULL terminated), memory must be MemFree()

Decode Base64 string. Free with `memFree`.

Zigfn decodeDataBase64(text: [:0]const u8) error{DecodeFailed}![]u8
Cunsigned char *DecodeDataBase64(const char *text, int *outputSize);

rl.computeCRC32

Compute CRC32 hash code

Compute CRC32 hash code.

Zigfn computeCRC32(data: []const u8) u32
Cunsigned int ComputeCRC32(const unsigned char *data, int dataSize);

Used in core_compute_hash.

rl.computeMD5

Compute MD5 hash code, returns static int[4] (16 bytes)

Compute MD5 hash code (returned array lives in a static buffer).

Zigfn computeMD5(data: []const u8) *const [4]u32
Cunsigned int *ComputeMD5(const unsigned char *data, int dataSize);

Used in core_compute_hash.

rl.computeSHA1

Compute SHA1 hash code, returns static int[5] (20 bytes)

Compute SHA1 hash code (returned array lives in a static buffer).

Zigfn computeSHA1(data: []const u8) *const [5]u32
Cunsigned int *ComputeSHA1(const unsigned char *data, int dataSize);

Used in core_compute_hash.

rl.computeSHA256

Compute SHA256 hash code, returns static int[8] (32 bytes)

Compute SHA256 hash code (returned array lives in a static buffer).

Zigfn computeSHA256(data: []const u8) *const [8]u32
Cunsigned int *ComputeSHA256(const unsigned char *data, int dataSize);

Used in core_compute_hash.

Automation events functionality

rl.loadAutomationEventList

Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS

Zigfn loadAutomationEventList(fileName: ?[:0]const u8) AutomationEventList
CAutomationEventList LoadAutomationEventList(const char *fileName);

Used in core_automation_events.

rl.exportAutomationEventList

Export automation events list as text file

Zigfn exportAutomationEventList(list: AutomationEventList, fileName: [:0]const u8) bool
Cbool ExportAutomationEventList(AutomationEventList list, const char *fileName);

Used in core_automation_events.

Input-related functions: keyboard

rl.isKeyUp

Check if key is NOT being pressed

Zigfn isKeyUp(key: KeyboardKey) bool
Cbool IsKeyUp(int key);

rl.getKeyPressed

Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty

Zigfn getKeyPressed() KeyboardKey
Cint GetKeyPressed(void);

Used in core_keyboard_testbed.

rl.getKeyName

Get name of a QWERTY key on the current keyboard layout (eg returns string 'q' for KEY_A on an AZERTY keyboard)

Zigfn getKeyName(key: KeyboardKey) ?[:0]const u8
Cconst char *GetKeyName(int key);

Input-related functions: gamepads

rl.isGamepadButtonPressed

Check if gamepad button has been pressed once

Zigfn isGamepadButtonPressed(gamepad: i32, button: GamepadButton) bool
Cbool IsGamepadButtonPressed(int gamepad, int button);

Used in core_input_actions.

rl.isGamepadButtonReleased

Check if gamepad button has been released once

Zigfn isGamepadButtonReleased(gamepad: i32, button: GamepadButton) bool
Cbool IsGamepadButtonReleased(int gamepad, int button);

Used in core_input_actions.

rl.isGamepadButtonUp

Check if gamepad button is NOT being pressed

Zigfn isGamepadButtonUp(gamepad: i32, button: GamepadButton) bool
Cbool IsGamepadButtonUp(int gamepad, int button);

rl.setGamepadMappings

Set internal gamepad mappings (SDL_GameControllerDB)

Zigfn setGamepadMappings(mappings: [:0]const u8) i32
Cint SetGamepadMappings(const char *mappings);

rl.setGamepadVibration

Set gamepad vibration for both motors (duration in seconds)

Zigfn setGamepadVibration(gamepad: i32, leftMotor: f32, rightMotor: f32, duration: f32) void
Cvoid SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration);

Used in core_input_gamepad.

Input-related functions: mouse

rl.isMouseButtonUp

Check if mouse button is NOT being pressed

Zigfn isMouseButtonUp(button: MouseButton) bool
Cbool IsMouseButtonUp(int button);

Input-related functions: touch

rl.getTouchX

Get touch position X for touch point 0 (relative to screen size)

Zigfn getTouchX() i32
Cint GetTouchX(void);

rl.getTouchY

Get touch position Y for touch point 0 (relative to screen size)

Zigfn getTouchY() i32
Cint GetTouchY(void);

rl.getTouchPointId

Get touch point identifier for provided index

Zigfn getTouchPointId(index: i32) i32
Cint GetTouchPointId(int index);