Skip to content

Add more SDL3 related functions #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/sdl3.zig
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ extern fn SDL_Init(flags: InitFlags) i32;
pub const quit = SDL_Quit;
extern fn SDL_Quit() void;

pub const setMainReady = SDL_SetMainReady;
extern fn SDL_SetMainReady() void;

//--------------------------------------------------------------------------------------------------
//
// Configuration Variables
Expand All @@ -64,6 +67,11 @@ pub fn setHint(name: [:0]const u8, value: [:0]const u8) bool {
}
extern fn SDL_SetHint(name: [*:0]const u8, value: [*:0]const u8) Bool;

pub fn setAppMetadata(name: [:0]const u8, version: [:0]const u8, identifier: [:0]const u8) Error!void {
if (SDL_SetAppMetadata(name, version, identifier) == False) return makeError();
}
extern fn SDL_SetAppMetadata(appname: [*:0]const u8, appversion: [*:0]const u8, appidentifier: [*:0]const u8) Bool;

//--------------------------------------------------------------------------------------------------
//
// Error Handling
Expand Down Expand Up @@ -422,6 +430,7 @@ pub const Renderer = opaque {
pub const create = createRenderer;
pub const destroy = destroyRenderer;
pub const present = renderPresent;
pub const debugText = renderDebugText;
};

/// Get the number of 2D rendering drivers available for the current display.
Expand Down Expand Up @@ -757,6 +766,11 @@ extern fn SDL_RenderReadPixels(
pitch: c_int,
) c_int;

pub fn renderDebugText(renderer: *Renderer, x: f32, y: f32, str: [*:0]const u8) Error!void {
if (SDL_RenderDebugText(renderer, x, y, str) == False) return makeError();
}
extern fn SDL_RenderDebugText(renderer: *Renderer, x: f32, y: f32, str: [*:0]const u8) Bool;

//--------------------------------------------------------------------------------------------------
//
// Pixel Formats and Conversion Routines (SDL_pixels.h)
Expand Down