Backlog/lib/sdl3/src/sdl3.zig

69 lines
1.5 KiB
Zig

pub const c = @import("c.zig").c;
pub const events = @import("events.zig");
pub const InitOptions = packed struct(c_int) {
pad0: u4 = 0, // 0 - 3
audio: bool = false, // 4
video: bool = false, // 5
pad1: u2 = 0, // 6-7
pad2: u1 = 0, // 8
joystick: bool = false, // 9
pad3: u2 = 0, // 10-11
haptic: bool = false, // 12
gamepad: bool = false,
events: bool = false,
sensor: bool = false,
camera: bool = false,
pad4: u3 = 0,
pad5: u12 = 0,
};
pub const AppResult = enum {
app_continue,
app_success,
app_failure,
};
pub const Window = c.SDL_Window;
pub const Event = c.SDL_Event;
pub const Rect = c.SDL_Rect;
pub fn init(options: InitOptions) !void {
if (!c.SDL_Init(@bitCast(options))) {
return error.InitFailed;
}
}
pub const EventType = events;
var gLastEvent: Event = undefined;
pub fn pollEvent() ?*Event {
if (c.SDL_PollEvent(&gLastEvent)) {
return &gLastEvent;
}
return null;
}
pub fn getMouseState(x: *f32, y: *f32) void {
_ = c.SDL_GetMouseState(@ptrCast(x), @ptrCast(y));
}
pub fn getError() [*c]const u8 {
return c.SDL_GetError();
}
pub fn hideCursor() void {
_ = c.SDL_HideCursor();
}
pub fn showCursor() void {
_ = c.SDL_ShowCursor();
}
pub const SDLVTable = @import("SDLVTable.zig");
const std = @import("std");
pub const gpu = @import("gpu.zig");
pub const Scancode = @import("scancode.zig").Scancode;
pub const shaderTypes = @import("shaderTypes");