dev/sdl3-parser #1

Open
peterino wants to merge 51 commits from dev/sdl3-parser into dev/variant-engine
16 changed files with 2338 additions and 72 deletions
Showing only changes of commit 724b5e1a05 - Show all commits

11
lib/sdl3/build.zig vendored
View File

@ -148,6 +148,17 @@ pub fn build(b: *std.Build) void {
.{ .header = "SDL/include/SDL3/SDL_video.h", .output = "v2/video.zig" },
.{ .header = "SDL/include/SDL3/SDL_events.h", .output = "v2/events.zig" },
.{ .header = "SDL/include/SDL3/SDL_keyboard.h", .output = "v2/keyboard.zig" },
.{ .header = "SDL/include/SDL3/SDL_mouse.h", .output = "v2/mouse.zig" },
.{ .header = "SDL/include/SDL3/SDL_scancode.h", .output = "v2/scancode.zig" },
.{ .header = "SDL/include/SDL3/SDL_keycode.h", .output = "v2/keycode.zig" },
.{ .header = "SDL/include/SDL3/SDL_pixels.h", .output = "v2/pixels.zig" },
.{ .header = "SDL/include/SDL3/SDL_rect.h", .output = "v2/rect.zig" },
.{ .header = "SDL/include/SDL3/SDL_surface.h", .output = "v2/surface.zig" },
.{ .header = "SDL/include/SDL3/SDL_blendmode.h", .output = "v2/blendmode.zig" },
.{ .header = "SDL/include/SDL3/SDL_init.h", .output = "v2/init.zig" },
.{ .header = "SDL/include/SDL3/SDL_timer.h", .output = "v2/timer.zig" },
.{ .header = "SDL/include/SDL3/SDL_error.h", .output = "v2/error.zig" },
.{ .header = "SDL/include/SDL3/SDL_iostream.h", .output = "v2/iostream.zig" },
};
const regenerate_step = b.step("regenerate-zig", "Regenerate bindings from SDL headers");

15
lib/sdl3/v2/blendmode.zig vendored Normal file
View File

@ -0,0 +1,15 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const BlendMode = u32;
pub inline fn composeCustomBlendMode(
srcColorFactor: BlendFactor,
dstColorFactor: BlendFactor,
colorOperation: BlendOperation,
srcAlphaFactor: BlendFactor,
dstAlphaFactor: BlendFactor,
alphaOperation: BlendOperation,
) BlendMode {
return @intFromEnum(c.SDL_ComposeCustomBlendMode(srcColorFactor, dstColorFactor, @intFromEnum(colorOperation), srcAlphaFactor, dstAlphaFactor, @intFromEnum(alphaOperation)));
}

24
lib/sdl3/v2/error.zig vendored Normal file
View File

@ -0,0 +1,24 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub inline fn setError(fmt: [*c]const u8, ...) bool {
return c.SDL_SetError(
fmt,
);
}
pub inline fn setErrorV(fmt: [*c]const u8, ap: std.builtin.VaList) bool {
return c.SDL_SetErrorV(fmt, ap);
}
pub inline fn outOfMemory() bool {
return c.SDL_OutOfMemory();
}
pub inline fn getError() [*c]const u8 {
return c.SDL_GetError();
}
pub inline fn clearError() bool {
return c.SDL_ClearError();
}

491
lib/sdl3/v2/events.zig vendored
View File

@ -1,10 +1,236 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const PenID = u32;
pub const WindowID = u32;
pub const AudioDeviceID = u32;
pub const DisplayID = u32;
pub const CameraID = u32;
pub const PenInputFlags = packed struct(u32) {
penInputDown: bool = false, // pen is pressed down
penInputButton1: bool = false, // button 1 is pressed
penInputButton2: bool = false, // button 2 is pressed
penInputButton3: bool = false, // button 3 is pressed
penInputButton4: bool = false, // button 4 is pressed
penInputButton5: bool = false, // button 5 is pressed
penInputEraserTip: bool = false, // eraser tip is used
pad0: u24 = 0,
rsvd: bool = false,
};
pub const MouseButtonFlags = packed struct(u32) {
buttonLeft: bool = false,
buttonMiddle: bool = false,
buttonX1: bool = false,
pad0: u28 = 0,
rsvd: bool = false,
};
pub const Scancode = enum(c_int) {
scancodeUnknown,
scancodeA,
scancodeB,
scancodeC,
scancodeD,
scancodeE,
scancodeF,
scancodeG,
scancodeH,
scancodeI,
scancodeJ,
scancodeK,
scancodeL,
scancodeM,
scancodeN,
scancodeO,
scancodeP,
scancodeQ,
scancodeR,
scancodeS,
scancodeT,
scancodeU,
scancodeV,
scancodeW,
scancodeX,
scancodeY,
scancodeZ,
scancode1,
scancode2,
scancode3,
scancode4,
scancode5,
scancode6,
scancode7,
scancode8,
scancode9,
scancode0,
scancodeReturn,
scancodeEscape,
scancodeBackspace,
scancodeTab,
scancodeSpace,
scancodeMinus,
scancodeEquals,
scancodeLeftbracket,
scancodeRightbracket,
scancodeSemicolon,
scancodeApostrophe,
scancodeComma,
scancodePeriod,
scancodeSlash,
scancodeCapslock,
scancodeF1,
scancodeF2,
scancodeF3,
scancodeF4,
scancodeF5,
scancodeF6,
scancodeF7,
scancodeF8,
scancodeF9,
scancodeF10,
scancodeF11,
scancodeF12,
scancodePrintscreen,
scancodeScrolllock,
scancodePause,
scancodeHome,
scancodePageup,
scancodeDelete,
scancodeEnd,
scancodePagedown,
scancodeRight,
scancodeLeft,
scancodeDown,
scancodeUp,
scancodeKpDivide,
scancodeKpMultiply,
scancodeKpMinus,
scancodeKpPlus,
scancodeKpEnter,
scancodeKp1,
scancodeKp2,
scancodeKp3,
scancodeKp4,
scancodeKp5,
scancodeKp6,
scancodeKp7,
scancodeKp8,
scancodeKp9,
scancodeKp0,
scancodeKpPeriod,
scancodeKpEquals,
scancodeF13,
scancodeF14,
scancodeF15,
scancodeF16,
scancodeF17,
scancodeF18,
scancodeF19,
scancodeF20,
scancodeF21,
scancodeF22,
scancodeF23,
scancodeF24,
scancodeExecute,
scancodeSelect,
scancodeMute,
scancodeVolumeup,
scancodeVolumedown,
scancodeKpComma,
scancodeKpEqualsas400,
scancodeInternational2,
scancodeInternational4,
scancodeInternational5,
scancodeInternational6,
scancodeInternational7,
scancodeInternational8,
scancodeInternational9,
scancodeSysreq,
scancodeClear,
scancodePrior,
scancodeReturn2,
scancodeSeparator,
scancodeOut,
scancodeOper,
scancodeClearagain,
scancodeCrsel,
scancodeExsel,
scancodeKp00,
scancodeKp000,
scancodeThousandsseparator,
scancodeDecimalseparator,
scancodeCurrencyunit,
scancodeCurrencysubunit,
scancodeKpLeftparen,
scancodeKpRightparen,
scancodeKpLeftbrace,
scancodeKpRightbrace,
scancodeKpTab,
scancodeKpBackspace,
scancodeKpA,
scancodeKpB,
scancodeKpC,
scancodeKpD,
scancodeKpE,
scancodeKpF,
scancodeKpXor,
scancodeKpPower,
scancodeKpPercent,
scancodeKpLess,
scancodeKpGreater,
scancodeKpAmpersand,
scancodeKpDblampersand,
scancodeKpVerticalbar,
scancodeKpDblverticalbar,
scancodeKpColon,
scancodeKpHash,
scancodeKpSpace,
scancodeKpAt,
scancodeKpExclam,
scancodeKpMemstore,
scancodeKpMemrecall,
scancodeKpMemclear,
scancodeKpMemadd,
scancodeKpMemsubtract,
scancodeKpMemmultiply,
scancodeKpMemdivide,
scancodeKpPlusminus,
scancodeKpClear,
scancodeKpClearentry,
scancodeKpBinary,
scancodeKpOctal,
scancodeKpDecimal,
scancodeKpHexadecimal,
scancodeLctrl,
scancodeLshift,
scancodeRctrl,
scancodeRshift,
};
pub const TouchID = u64;
pub const KeyboardID = u32;
pub const MouseID = u32;
pub const Window = opaque {};
pub const FingerID = u64;
pub const Keycode = u32;
pub const SensorID = u32;
pub const JoystickID = u32;
pub const Keymod = u16;
pub const EventType = enum(c_int) {
eventDisplayFirst,
eventDisplayLast,
@ -24,188 +250,440 @@ pub const EventType = enum(c_int) {
};
pub const CommonEvent = extern struct {
type: u32, // Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
};
pub const DisplayEvent = extern struct {
type: EventType, // SDL_DISPLAYEVENT_*
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
displayID: DisplayID, // The associated display
data1: i32, // event dependent data
data2: i32, // event dependent data
};
pub const WindowEvent = extern struct {
type: EventType, // SDL_EVENT_WINDOW_*
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The associated window
data1: i32, // event dependent data
data2: i32, // event dependent data
};
pub const KeyboardDeviceEvent = extern struct {
type: EventType, // SDL_EVENT_KEYBOARD_ADDED or SDL_EVENT_KEYBOARD_REMOVED
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: KeyboardID, // The keyboard instance id
};
pub const KeyboardEvent = extern struct {
type: EventType, // SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with keyboard focus, if any
which: KeyboardID, // The keyboard instance id, or 0 if unknown or virtual
scancode: Scancode, // SDL physical key code
key: Keycode, // SDL virtual key code
mod: Keymod, // current key modifiers
raw: u16, // The platform dependent scancode for this event
down: bool, // true if the key is pressed
repeat: bool, // true if this is a key repeat
};
pub const TextEditingEvent = extern struct {
type: EventType, // SDL_EVENT_TEXT_EDITING
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with keyboard focus, if any
text: [*c]const u8, // The editing text
start: i32, // The start cursor of selected editing text, or -1 if not set
length: i32, // The length of selected editing text, or -1 if not set
};
pub const TextEditingCandidatesEvent = extern struct {
type: EventType, // SDL_EVENT_TEXT_EDITING_CANDIDATES
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with keyboard focus, if any
candidates: [*c]const [*c]const u8, // The list of candidates, or NULL if there are no candidates available
num_candidates: i32, // The number of strings in `candidates`
selected_candidate: i32, // The index of the selected candidate, or -1 if no candidate is selected
horizontal: bool, // true if the list is horizontal, false if it's vertical
padding1: u8,
padding2: u8,
padding3: u8,
};
pub const TextInputEvent = extern struct {
type: EventType, // SDL_EVENT_TEXT_INPUT
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with keyboard focus, if any
text: [*c]const u8, // The input text, UTF-8 encoded
};
pub const MouseDeviceEvent = extern struct {
type: EventType, // SDL_EVENT_MOUSE_ADDED or SDL_EVENT_MOUSE_REMOVED
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: MouseID, // The mouse instance id
};
pub const MouseMotionEvent = extern struct {
type: EventType, // SDL_EVENT_MOUSE_MOTION
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with mouse focus, if any
which: MouseID, // The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0
state: MouseButtonFlags, // The current button state
x: f32, // X coordinate, relative to window
y: f32, // Y coordinate, relative to window
xrel: f32, // The relative motion in the X direction
yrel: f32, // The relative motion in the Y direction
};
pub const MouseButtonEvent = extern struct {
type: EventType, // SDL_EVENT_MOUSE_BUTTON_DOWN or SDL_EVENT_MOUSE_BUTTON_UP
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with mouse focus, if any
which: MouseID, // The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0
button: u8, // The mouse button index
down: bool, // true if the button is pressed
clicks: u8, // 1 for single-click, 2 for double-click, etc.
padding: u8,
x: f32, // X coordinate, relative to window
y: f32, // Y coordinate, relative to window
};
pub const MouseWheelEvent = extern struct {
type: EventType, // SDL_EVENT_MOUSE_WHEEL
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with mouse focus, if any
which: MouseID, // The mouse instance id in relative mode or 0
x: f32, // The amount scrolled horizontally, positive to the right and negative to the left
y: f32, // The amount scrolled vertically, positive away from the user and negative toward the user
direction: MouseWheelDirection, // Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back
mouse_x: f32, // X coordinate, relative to window
mouse_y: f32, // Y coordinate, relative to window
};
pub const JoyAxisEvent = extern struct {
type: EventType, // SDL_EVENT_JOYSTICK_AXIS_MOTION
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
axis: u8, // The joystick axis index
padding1: u8,
padding2: u8,
padding3: u8,
value: i16, // The axis value (range: -32768 to 32767)
padding4: u16,
};
pub const JoyBallEvent = extern struct {
type: EventType, // SDL_EVENT_JOYSTICK_BALL_MOTION
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
ball: u8, // The joystick trackball index
padding1: u8,
padding2: u8,
padding3: u8,
xrel: i16, // The relative motion in the X direction
yrel: i16, // The relative motion in the Y direction
};
pub const JoyHatEvent = extern struct {
type: EventType, // SDL_EVENT_JOYSTICK_HAT_MOTION
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
hat: u8, // The joystick hat index
padding1: u8,
padding2: u8,
};
pub const JoyButtonEvent = extern struct {
type: EventType, // SDL_EVENT_JOYSTICK_BUTTON_DOWN or SDL_EVENT_JOYSTICK_BUTTON_UP
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
button: u8, // The joystick button index
down: bool, // true if the button is pressed
padding1: u8,
padding2: u8,
};
pub const JoyDeviceEvent = extern struct {
type: EventType, // SDL_EVENT_JOYSTICK_ADDED or SDL_EVENT_JOYSTICK_REMOVED or SDL_EVENT_JOYSTICK_UPDATE_COMPLETE
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
};
pub const JoyBatteryEvent = extern struct {
type: EventType, // SDL_EVENT_JOYSTICK_BATTERY_UPDATED
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
state: PowerState, // The joystick battery state
percent: c_int, // The joystick battery percent charge remaining
};
pub const GamepadAxisEvent = extern struct {
type: EventType, // SDL_EVENT_GAMEPAD_AXIS_MOTION
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
axis: u8, // The gamepad axis (SDL_GamepadAxis)
padding1: u8,
padding2: u8,
padding3: u8,
value: i16, // The axis value (range: -32768 to 32767)
padding4: u16,
};
pub const GamepadButtonEvent = extern struct {
type: EventType, // SDL_EVENT_GAMEPAD_BUTTON_DOWN or SDL_EVENT_GAMEPAD_BUTTON_UP
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
button: u8, // The gamepad button (SDL_GamepadButton)
down: bool, // true if the button is pressed
padding1: u8,
padding2: u8,
};
pub const GamepadDeviceEvent = extern struct {
type: EventType, // SDL_EVENT_GAMEPAD_ADDED, SDL_EVENT_GAMEPAD_REMOVED, or SDL_EVENT_GAMEPAD_REMAPPED, SDL_EVENT_GAMEPAD_UPDATE_COMPLETE or SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
};
pub const GamepadTouchpadEvent = extern struct {
type: EventType, // SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN or SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION or SDL_EVENT_GAMEPAD_TOUCHPAD_UP
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
touchpad: i32, // The index of the touchpad
finger: i32, // The index of the finger on the touchpad
x: f32, // Normalized in the range 0...1 with 0 being on the left
y: f32, // Normalized in the range 0...1 with 0 being at the top
pressure: f32, // Normalized in the range 0...1
};
pub const GamepadSensorEvent = extern struct {
type: EventType, // SDL_EVENT_GAMEPAD_SENSOR_UPDATE
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: JoystickID, // The joystick instance id
sensor: i32, // The type of the sensor, one of the values of SDL_SensorType
data: [3]f32, // Up to 3 values from the sensor, as defined in SDL_sensor.h
sensor_timestamp: u64, // The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock
};
pub const AudioDeviceEvent = extern struct {
type: EventType, // SDL_EVENT_AUDIO_DEVICE_ADDED, or SDL_EVENT_AUDIO_DEVICE_REMOVED, or SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: AudioDeviceID, // SDL_AudioDeviceID for the device being added or removed or changing
recording: bool, // false if a playback device, true if a recording device.
padding1: u8,
padding2: u8,
padding3: u8,
};
pub const CameraDeviceEvent = extern struct {
type: EventType, // SDL_EVENT_CAMERA_DEVICE_ADDED, SDL_EVENT_CAMERA_DEVICE_REMOVED, SDL_EVENT_CAMERA_DEVICE_APPROVED, SDL_EVENT_CAMERA_DEVICE_DENIED
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: CameraID, // SDL_CameraID for the device being added or removed or changing
};
pub const RenderEvent = extern struct {
type: EventType, // SDL_EVENT_RENDER_TARGETS_RESET, SDL_EVENT_RENDER_DEVICE_RESET, SDL_EVENT_RENDER_DEVICE_LOST
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window containing the renderer in question.
};
pub const TouchFingerEvent = extern struct {
type: EventType, // SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_UP, SDL_EVENT_FINGER_MOTION, or SDL_EVENT_FINGER_CANCELED
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
touchID: TouchID, // The touch device id
fingerID: FingerID,
x: f32, // Normalized in the range 0...1
y: f32, // Normalized in the range 0...1
dx: f32, // Normalized in the range -1...1
dy: f32, // Normalized in the range -1...1
pressure: f32, // Normalized in the range 0...1
windowID: WindowID, // The window underneath the finger, if any
};
pub const PenProximityEvent = extern struct {
type: EventType, // SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with pen focus, if any
which: PenID, // The pen instance id
};
pub const PenMotionEvent = extern struct {
type: EventType, // SDL_EVENT_PEN_MOTION
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with pen focus, if any
which: PenID, // The pen instance id
pen_state: PenInputFlags, // Complete pen input state at time of event
x: f32, // X coordinate, relative to window
y: f32, // Y coordinate, relative to window
};
pub const PenTouchEvent = extern struct {
type: EventType, // SDL_EVENT_PEN_DOWN or SDL_EVENT_PEN_UP
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with pen focus, if any
which: PenID, // The pen instance id
pen_state: PenInputFlags, // Complete pen input state at time of event
x: f32, // X coordinate, relative to window
y: f32, // Y coordinate, relative to window
eraser: bool, // true if eraser end is used (not all pens support this).
down: bool, // true if the pen is touching or false if the pen is lifted off
};
pub const PenButtonEvent = extern struct {
type: EventType, // SDL_EVENT_PEN_BUTTON_DOWN or SDL_EVENT_PEN_BUTTON_UP
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with mouse focus, if any
which: PenID, // The pen instance id
pen_state: PenInputFlags, // Complete pen input state at time of event
x: f32, // X coordinate, relative to window
y: f32, // Y coordinate, relative to window
button: u8, // The pen button index (first button is 1).
down: bool, // true if the button is pressed
};
pub const PenAxisEvent = extern struct {
type: EventType, // SDL_EVENT_PEN_AXIS
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window with pen focus, if any
which: PenID, // The pen instance id
pen_state: PenInputFlags, // Complete pen input state at time of event
x: f32, // X coordinate, relative to window
y: f32, // Y coordinate, relative to window
axis: PenAxis, // Axis that has changed
value: f32, // New value of axis
};
pub const DropEvent = extern struct {
type: EventType, // SDL_EVENT_DROP_BEGIN or SDL_EVENT_DROP_FILE or SDL_EVENT_DROP_TEXT or SDL_EVENT_DROP_COMPLETE or SDL_EVENT_DROP_POSITION
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The window that was dropped on, if any
x: f32, // X coordinate, relative to window (not on begin)
y: f32, // Y coordinate, relative to window (not on begin)
source: [*c]const u8, // The source app that sent this drop event, or NULL if that isn't available
data: [*c]const u8, // The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events
};
pub const ClipboardEvent = extern struct {
type: EventType, // SDL_EVENT_CLIPBOARD_UPDATE
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
owner: bool, // are we owning the clipboard (internal update)
num_mime_types: i32, // number of mime types
mime_types: [*c][*c]const u8, // current mime types
};
pub const SensorEvent = extern struct {
type: EventType, // SDL_EVENT_SENSOR_UPDATE
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
which: SensorID, // The instance ID of the sensor
data: [6]f32, // Up to 6 values from the sensor - additional values can be queried using SDL_GetSensorData()
sensor_timestamp: u64, // The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock
};
pub const QuitEvent = extern struct {
type: EventType, // SDL_EVENT_QUIT
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
};
pub const UserEvent = extern struct {
type: u32, // SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
windowID: WindowID, // The associated window if any
code: i32, // User defined event code
data1: ?*anyopaque, // User defined data pointer
data2: ?*anyopaque, // User defined data pointer
};
pub const Event = union;
pub const Event = extern union {
type: u32, // Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration
common: CommonEvent, // Common event data
display: DisplayEvent, // Display event data
window: WindowEvent, // Window event data
kdevice: KeyboardDeviceEvent, // Keyboard device change event data
key: KeyboardEvent, // Keyboard event data
edit: TextEditingEvent, // Text editing event data
edit_candidates: TextEditingCandidatesEvent, // Text editing candidates event data
text: TextInputEvent, // Text input event data
mdevice: MouseDeviceEvent, // Mouse device change event data
motion: MouseMotionEvent, // Mouse motion event data
button: MouseButtonEvent, // Mouse button event data
wheel: MouseWheelEvent, // Mouse wheel event data
jdevice: JoyDeviceEvent, // Joystick device change event data
jaxis: JoyAxisEvent, // Joystick axis event data
jball: JoyBallEvent, // Joystick ball event data
jhat: JoyHatEvent, // Joystick hat event data
jbutton: JoyButtonEvent, // Joystick button event data
jbattery: JoyBatteryEvent, // Joystick battery event data
gdevice: GamepadDeviceEvent, // Gamepad device event data
gaxis: GamepadAxisEvent, // Gamepad axis event data
gbutton: GamepadButtonEvent, // Gamepad button event data
gtouchpad: GamepadTouchpadEvent, // Gamepad touchpad event data
gsensor: GamepadSensorEvent, // Gamepad sensor event data
adevice: AudioDeviceEvent, // Audio device event data
cdevice: CameraDeviceEvent, // Camera device event data
sensor: SensorEvent, // Sensor event data
quit: QuitEvent, // Quit request event data
user: UserEvent, // Custom event data
tfinger: TouchFingerEvent, // Touch finger event data
pproximity: PenProximityEvent, // Pen proximity event data
ptouch: PenTouchEvent, // Pen tip touching event data
pmotion: PenMotionEvent, // Pen motion event data
pbutton: PenButtonEvent, // Pen button event data
paxis: PenAxisEvent, // Pen axis event data
render: RenderEvent, // Render event data
drop: DropEvent, // Drag and drop event data
clipboard: ClipboardEvent, // Clipboard event data
padding: [128]u8,
};
pub inline fn pumpEvents() void {
return c.SDL_PumpEvents();
}
pub const EventAction = enum(c_int) {
};
pub inline fn peepEvents(events: ?*Event, numevents: c_int, action: EventAction, minType: u32, maxType: u32,) c_int {
pub inline fn peepEvents(
events: ?*Event,
numevents: c_int,
action: EventAction,
minType: u32,
maxType: u32,
) c_int {
return c.SDL_PeepEvents(events, numevents, action, minType, maxType);
}
@ -241,7 +719,7 @@ pub inline fn pushEvent(event: ?*Event) bool {
return c.SDL_PushEvent(event);
}
pub const EventFilter = *const fn(userdata: ?*anyopaque, event: ?*Event) callconv(.C) bool;
pub const EventFilter = *const fn (userdata: ?*anyopaque, event: ?*Event) callconv(.C) bool;
pub inline fn setEventFilter(filter: EventFilter, userdata: ?*anyopaque) void {
return c.SDL_SetEventFilter(filter, userdata);
@ -278,4 +756,3 @@ pub inline fn registerEvents(numevents: c_int) u32 {
pub inline fn getWindowFromEvent(event: *const Event) ?*Window {
return c.SDL_GetWindowFromEvent(@ptrCast(event));
}

301
lib/sdl3/v2/gpu.zig vendored
View File

@ -10,8 +10,6 @@ pub const FColor = extern struct {
pub const PropertiesID = u32;
pub const Window = opaque {};
pub const Rect = extern struct {
x: c_int,
y: c_int,
@ -19,6 +17,8 @@ pub const Rect = extern struct {
h: c_int,
};
pub const Window = opaque {};
pub const GPUDevice = opaque {
pub inline fn destroyGPUDevice(gpudevice: *GPUDevice) void {
return c.SDL_DestroyGPUDevice(gpudevice);
@ -544,14 +544,6 @@ pub const GPUCopyPass = opaque {
pub const GPUFence = opaque {};
pub const GPUPrimitiveType = enum(c_int) {};
pub const GPULoadOp = enum(c_int) {};
pub const GPUStoreOp = enum(c_int) {};
pub const GPUIndexElementSize = enum(c_int) {};
pub const GPUTextureFormat = enum(c_int) {
textureformatInvalid,
textureformatA8Unorm,
@ -672,10 +664,6 @@ pub const GPUTextureUsageFlags = packed struct(u32) {
rsvd: bool = false,
};
pub const GPUTextureType = enum(c_int) {};
pub const GPUSampleCount = enum(c_int) {};
pub const GPUCubeMapFace = enum(c_int) {
cubemapfacePositivex,
cubemapfaceNegativex,
@ -742,14 +730,6 @@ pub const GPUVertexElementFormat = enum(c_int) {
vertexelementformatHalf4,
};
pub const GPUVertexInputRate = enum(c_int) {};
pub const GPUFillMode = enum(c_int) {};
pub const GPUCullMode = enum(c_int) {};
pub const GPUFrontFace = enum(c_int) {};
pub const GPUCompareOp = enum(c_int) {
compareopInvalid,
};
@ -775,12 +755,6 @@ pub const GPUColorComponentFlags = packed struct(u8) {
rsvd: bool = false,
};
pub const GPUFilter = enum(c_int) {};
pub const GPUSamplerMipmapMode = enum(c_int) {};
pub const GPUSamplerAddressMode = enum(c_int) {};
pub const GPUPresentMode = enum(c_int) {
presentmodeVsync,
presentmodeImmediate,
@ -794,110 +768,333 @@ pub const GPUSwapchainComposition = enum(c_int) {
swapchaincompositionHdr10St2084,
};
pub const GPUViewport = extern struct {};
pub const GPUViewport = extern struct {
x: f32, // The left offset of the viewport.
y: f32, // The top offset of the viewport.
w: f32, // The width of the viewport.
h: f32, // The height of the viewport.
min_depth: f32, // The minimum depth of the viewport.
max_depth: f32, // The maximum depth of the viewport.
};
pub const GPUTextureTransferInfo = extern struct {};
pub const GPUTextureTransferInfo = extern struct {
transfer_buffer: ?*GPUTransferBuffer, // The transfer buffer used in the transfer operation.
offset: u32, // The starting byte of the image data in the transfer buffer.
pixels_per_row: u32, // The number of pixels from one row to the next.
rows_per_layer: u32, // The number of rows from one layer/depth-slice to the next.
};
pub const GPUTransferBufferLocation = extern struct {};
pub const GPUTransferBufferLocation = extern struct {
transfer_buffer: ?*GPUTransferBuffer, // The transfer buffer used in the transfer operation.
offset: u32, // The starting byte of the buffer data in the transfer buffer.
};
pub const GPUTextureLocation = extern struct {};
pub const GPUTextureLocation = extern struct {
texture: ?*GPUTexture, // The texture used in the copy operation.
mip_level: u32, // The mip level index of the location.
layer: u32, // The layer index of the location.
x: u32, // The left offset of the location.
y: u32, // The top offset of the location.
z: u32, // The front offset of the location.
};
pub const GPUTextureRegion = extern struct {};
pub const GPUTextureRegion = extern struct {
texture: ?*GPUTexture, // The texture used in the copy operation.
mip_level: u32, // The mip level index to transfer.
layer: u32, // The layer index to transfer.
x: u32, // The left offset of the region.
y: u32, // The top offset of the region.
z: u32, // The front offset of the region.
w: u32, // The width of the region.
h: u32, // The height of the region.
d: u32, // The depth of the region.
};
pub const GPUBlitRegion = extern struct {};
pub const GPUBlitRegion = extern struct {
texture: ?*GPUTexture, // The texture.
mip_level: u32, // The mip level index of the region.
layer_or_depth_plane: u32, // The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures.
x: u32, // The left offset of the region.
y: u32, // The top offset of the region.
w: u32, // The width of the region.
h: u32, // The height of the region.
};
pub const GPUBufferLocation = extern struct {};
pub const GPUBufferLocation = extern struct {
buffer: ?*GPUBuffer, // The buffer.
offset: u32, // The starting byte within the buffer.
};
pub const GPUBufferRegion = extern struct {};
pub const GPUBufferRegion = extern struct {
buffer: ?*GPUBuffer, // The buffer.
offset: u32, // The starting byte within the buffer.
size: u32, // The size in bytes of the region.
};
pub const GPUIndirectDrawCommand = extern struct {};
pub const GPUIndirectDrawCommand = extern struct {
num_vertices: u32, // The number of vertices to draw.
num_instances: u32, // The number of instances to draw.
first_vertex: u32, // The index of the first vertex to draw.
first_instance: u32, // The ID of the first instance to draw.
};
pub const GPUIndexedIndirectDrawCommand = extern struct {};
pub const GPUIndexedIndirectDrawCommand = extern struct {
num_indices: u32, // The number of indices to draw per instance.
num_instances: u32, // The number of instances to draw.
first_index: u32, // The base index within the index buffer.
vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer.
first_instance: u32, // The ID of the first instance to draw.
};
pub const GPUIndirectDispatchCommand = extern struct {};
pub const GPUIndirectDispatchCommand = extern struct {
groupcount_x: u32, // The number of local workgroups to dispatch in the X dimension.
groupcount_y: u32, // The number of local workgroups to dispatch in the Y dimension.
groupcount_z: u32, // The number of local workgroups to dispatch in the Z dimension.
};
pub const GPUSamplerCreateInfo = extern struct {
min_filter: GPUFilter, // The minification filter to apply to lookups.
mag_filter: GPUFilter, // The magnification filter to apply to lookups.
mipmap_mode: GPUSamplerMipmapMode, // The mipmap filter to apply to lookups.
address_mode_u: GPUSamplerAddressMode, // The addressing mode for U coordinates outside [0, 1).
address_mode_v: GPUSamplerAddressMode, // The addressing mode for V coordinates outside [0, 1).
address_mode_w: GPUSamplerAddressMode, // The addressing mode for W coordinates outside [0, 1).
mip_lod_bias: f32, // The bias to be added to mipmap LOD calculation.
max_anisotropy: f32, // The anisotropy value clamp used by the sampler. If enable_anisotropy is false, this is ignored.
compare_op: GPUCompareOp, // The comparison operator to apply to fetched data before filtering.
min_lod: f32, // Clamps the minimum of the computed LOD value.
max_lod: f32, // Clamps the maximum of the computed LOD value.
enable_anisotropy: bool, // true to enable anisotropic filtering.
enable_compare: bool, // true to enable comparison against a reference value during lookups.
padding1: u8,
padding2: u8,
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
};
pub const GPUVertexBufferDescription = extern struct {};
pub const GPUVertexBufferDescription = extern struct {
slot: u32, // The binding slot of the vertex buffer.
pitch: u32, // The byte pitch between consecutive elements of the vertex buffer.
input_rate: GPUVertexInputRate, // Whether attribute addressing is a function of the vertex index or instance index.
instance_step_rate: u32, // Reserved for future use. Must be set to 0.
};
pub const GPUVertexAttribute = extern struct {};
pub const GPUVertexAttribute = extern struct {
location: u32, // The shader input location index.
buffer_slot: u32, // The binding slot of the associated vertex buffer.
format: GPUVertexElementFormat, // The size and type of the attribute data.
offset: u32, // The byte offset of this attribute relative to the start of the vertex element.
};
pub const GPUVertexInputState = extern struct {};
pub const GPUVertexInputState = extern struct {
vertex_buffer_descriptions: *const GPUVertexBufferDescription, // A pointer to an array of vertex buffer descriptions.
num_vertex_buffers: u32, // The number of vertex buffer descriptions in the above array.
vertex_attributes: *const GPUVertexAttribute, // A pointer to an array of vertex attribute descriptions.
num_vertex_attributes: u32, // The number of vertex attribute descriptions in the above array.
};
pub const GPUStencilOpState = extern struct {};
pub const GPUStencilOpState = extern struct {
fail_op: GPUStencilOp, // The action performed on samples that fail the stencil test.
pass_op: GPUStencilOp, // The action performed on samples that pass the depth and stencil tests.
depth_fail_op: GPUStencilOp, // The action performed on samples that pass the stencil test and fail the depth test.
compare_op: GPUCompareOp, // The comparison operator used in the stencil test.
};
pub const GPUColorTargetBlendState = extern struct {
src_color_blendfactor: GPUBlendFactor, // The value to be multiplied by the source RGB value.
dst_color_blendfactor: GPUBlendFactor, // The value to be multiplied by the destination RGB value.
color_blend_op: GPUBlendOp, // The blend operation for the RGB components.
src_alpha_blendfactor: GPUBlendFactor, // The value to be multiplied by the source alpha.
dst_alpha_blendfactor: GPUBlendFactor, // The value to be multiplied by the destination alpha.
alpha_blend_op: GPUBlendOp, // The blend operation for the alpha component.
color_write_mask: GPUColorComponentFlags, // A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false.
enable_blend: bool, // Whether blending is enabled for the color target.
enable_color_write_mask: bool, // Whether the color write mask is enabled.
padding1: u8,
padding2: u8,
};
pub const GPUShaderCreateInfo = extern struct {};
pub const GPUShaderCreateInfo = extern struct {
code_size: usize, // The size in bytes of the code pointed to.
code: [*c]const u8, // A pointer to shader code.
entrypoint: [*c]const u8, // A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader.
format: GPUShaderFormat, // The format of the shader code.
stage: GPUShaderStage, // The stage the shader program corresponds to.
num_samplers: u32, // The number of samplers defined in the shader.
num_storage_textures: u32, // The number of storage textures defined in the shader.
num_storage_buffers: u32, // The number of storage buffers defined in the shader.
num_uniform_buffers: u32, // The number of uniform buffers defined in the shader.
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
};
pub const GPUTextureCreateInfo = extern struct {};
pub const GPUTextureCreateInfo = extern struct {
type: GPUTextureType, // The base dimensionality of the texture.
format: GPUTextureFormat, // The pixel format of the texture.
usage: GPUTextureUsageFlags, // How the texture is intended to be used by the client.
width: u32, // The width of the texture.
height: u32, // The height of the texture.
layer_count_or_depth: u32, // The layer count or depth of the texture. This value is treated as a layer count on 2D array textures, and as a depth value on 3D textures.
num_levels: u32, // The number of mip levels in the texture.
sample_count: GPUSampleCount, // The number of samples per texel. Only applies if the texture is used as a render target.
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
};
pub const GPUBufferCreateInfo = extern struct {};
pub const GPUBufferCreateInfo = extern struct {
usage: GPUBufferUsageFlags, // How the buffer is intended to be used by the client.
size: u32, // The size in bytes of the buffer.
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
};
pub const GPUTransferBufferCreateInfo = extern struct {};
pub const GPUTransferBufferCreateInfo = extern struct {
usage: GPUTransferBufferUsage, // How the transfer buffer is intended to be used by the client.
size: u32, // The size in bytes of the transfer buffer.
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
};
pub const GPURasterizerState = extern struct {
fill_mode: GPUFillMode, // Whether polygons will be filled in or drawn as lines.
cull_mode: GPUCullMode, // The facing direction in which triangles will be culled.
front_face: GPUFrontFace, // The vertex winding that will cause a triangle to be determined as front-facing.
depth_bias_constant_factor: f32, // A scalar factor controlling the depth value added to each fragment.
depth_bias_clamp: f32, // The maximum depth bias of a fragment.
depth_bias_slope_factor: f32, // A scalar factor applied to a fragment's slope in depth calculations.
enable_depth_bias: bool, // true to bias fragment depth values.
enable_depth_clip: bool, // true to enable depth clip, false to enable depth clamp.
padding1: u8,
padding2: u8,
};
pub const GPUMultisampleState = extern struct {
sample_count: GPUSampleCount, // The number of samples to be used in rasterization.
sample_mask: u32, // Reserved for future use. Must be set to 0.
enable_mask: bool, // Reserved for future use. Must be set to false.
padding1: u8,
padding2: u8,
padding3: u8,
};
pub const GPUDepthStencilState = extern struct {
compare_op: GPUCompareOp, // The comparison operator used for depth testing.
back_stencil_state: GPUStencilOpState, // The stencil op state for back-facing triangles.
front_stencil_state: GPUStencilOpState, // The stencil op state for front-facing triangles.
compare_mask: u8, // Selects the bits of the stencil values participating in the stencil test.
write_mask: u8, // Selects the bits of the stencil values updated by the stencil test.
enable_depth_test: bool, // true enables the depth test.
enable_depth_write: bool, // true enables depth writes. Depth writes are always disabled when enable_depth_test is false.
enable_stencil_test: bool, // true enables the stencil test.
padding1: u8,
padding2: u8,
padding3: u8,
};
pub const GPUColorTargetDescription = extern struct {};
pub const GPUColorTargetDescription = extern struct {
format: GPUTextureFormat, // The pixel format of the texture to be used as a color target.
blend_state: GPUColorTargetBlendState, // The blend state to be used for the color target.
};
pub const GPUGraphicsPipelineTargetInfo = extern struct {
color_target_descriptions: *const GPUColorTargetDescription, // A pointer to an array of color target descriptions.
num_color_targets: u32, // The number of color target descriptions in the above array.
depth_stencil_format: GPUTextureFormat, // The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false.
has_depth_stencil_target: bool, // true specifies that the pipeline uses a depth-stencil target.
padding1: u8,
padding2: u8,
padding3: u8,
};
pub const GPUGraphicsPipelineCreateInfo = extern struct {};
pub const GPUGraphicsPipelineCreateInfo = extern struct {
vertex_shader: ?*GPUShader, // The vertex shader used by the graphics pipeline.
fragment_shader: ?*GPUShader, // The fragment shader used by the graphics pipeline.
vertex_input_state: GPUVertexInputState, // The vertex layout of the graphics pipeline.
primitive_type: GPUPrimitiveType, // The primitive topology of the graphics pipeline.
rasterizer_state: GPURasterizerState, // The rasterizer state of the graphics pipeline.
multisample_state: GPUMultisampleState, // The multisample state of the graphics pipeline.
depth_stencil_state: GPUDepthStencilState, // The depth-stencil state of the graphics pipeline.
target_info: GPUGraphicsPipelineTargetInfo, // Formats and blend modes for the render targets of the graphics pipeline.
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
};
pub const GPUComputePipelineCreateInfo = extern struct {};
pub const GPUComputePipelineCreateInfo = extern struct {
code_size: usize, // The size in bytes of the compute shader code pointed to.
code: [*c]const u8, // A pointer to compute shader code.
entrypoint: [*c]const u8, // A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader.
format: GPUShaderFormat, // The format of the compute shader code.
num_samplers: u32, // The number of samplers defined in the shader.
num_readonly_storage_textures: u32, // The number of readonly storage textures defined in the shader.
num_readonly_storage_buffers: u32, // The number of readonly storage buffers defined in the shader.
num_readwrite_storage_textures: u32, // The number of read-write storage textures defined in the shader.
num_readwrite_storage_buffers: u32, // The number of read-write storage buffers defined in the shader.
num_uniform_buffers: u32, // The number of uniform buffers defined in the shader.
threadcount_x: u32, // The number of threads in the X dimension. This should match the value in the shader.
threadcount_y: u32, // The number of threads in the Y dimension. This should match the value in the shader.
threadcount_z: u32, // The number of threads in the Z dimension. This should match the value in the shader.
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
};
pub const GPUColorTargetInfo = extern struct {
texture: ?*GPUTexture, // The texture that will be used as a color target by a render pass.
mip_level: u32, // The mip level to use as a color target.
layer_or_depth_plane: u32, // The layer index or depth plane to use as a color target. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures.
clear_color: FColor, // The color to clear the color target to at the start of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used.
load_op: GPULoadOp, // What is done with the contents of the color target at the beginning of the render pass.
store_op: GPUStoreOp, // What is done with the results of the render pass.
resolve_texture: ?*GPUTexture, // The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used.
resolve_mip_level: u32, // The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used.
resolve_layer: u32, // The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used.
cycle: bool, // true cycles the texture if the texture is bound and load_op is not LOAD
cycle_resolve_texture: bool, // true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used.
padding1: u8,
padding2: u8,
};
pub const GPUDepthStencilTargetInfo = extern struct {
texture: ?*GPUTexture, // The texture that will be used as the depth stencil target by the render pass.
clear_depth: f32, // The value to clear the depth component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used.
load_op: GPULoadOp, // What is done with the depth contents at the beginning of the render pass.
store_op: GPUStoreOp, // What is done with the depth results of the render pass.
stencil_load_op: GPULoadOp, // What is done with the stencil contents at the beginning of the render pass.
stencil_store_op: GPUStoreOp, // What is done with the stencil results of the render pass.
cycle: bool, // true cycles the texture if the texture is bound and any load ops are not LOAD
clear_stencil: u8, // The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used.
padding1: u8,
padding2: u8,
};
pub const GPUBlitInfo = extern struct {
source: GPUBlitRegion, // The source region for the blit.
destination: GPUBlitRegion, // The destination region for the blit.
load_op: GPULoadOp, // What is done with the contents of the destination before the blit.
clear_color: FColor, // The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR.
flip_mode: FlipMode, // The flip mode for the source region.
filter: GPUFilter, // The filter mode used when blitting.
cycle: bool, // true cycles the destination texture if it is already bound.
padding1: u8,
padding2: u8,
padding3: u8,
};
pub const GPUBufferBinding = extern struct {};
pub const GPUBufferBinding = extern struct {
buffer: ?*GPUBuffer, // The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_VERTEX for SDL_BindGPUVertexBuffers, or SDL_GPU_BUFFERUSAGE_INDEX for SDL_BindGPUIndexBuffer.
offset: u32, // The starting byte of the data to bind in the buffer.
};
pub const GPUTextureSamplerBinding = extern struct {};
pub const GPUTextureSamplerBinding = extern struct {
texture: ?*GPUTexture, // The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
sampler: ?*GPUSampler, // The sampler to bind.
};
pub const GPUStorageBufferReadWriteBinding = extern struct {
buffer: ?*GPUBuffer, // The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE.
cycle: bool, // true cycles the buffer if it is already bound.
padding1: u8,
padding2: u8,
padding3: u8,
};
pub const GPUStorageTextureReadWriteBinding = extern struct {
texture: ?*GPUTexture, // The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE or SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE.
mip_level: u32, // The mip level index to bind.
layer: u32, // The layer index to bind.
cycle: bool, // true cycles the texture if it is already bound.
padding1: u8,
padding2: u8,
padding3: u8,

100
lib/sdl3/v2/init.zig vendored Normal file
View File

@ -0,0 +1,100 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const Event = extern union {
type: u32, // Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration
common: CommonEvent, // Common event data
display: DisplayEvent, // Display event data
window: WindowEvent, // Window event data
kdevice: KeyboardDeviceEvent, // Keyboard device change event data
key: KeyboardEvent, // Keyboard event data
edit: TextEditingEvent, // Text editing event data
edit_candidates: TextEditingCandidatesEvent, // Text editing candidates event data
text: TextInputEvent, // Text input event data
mdevice: MouseDeviceEvent, // Mouse device change event data
motion: MouseMotionEvent, // Mouse motion event data
button: MouseButtonEvent, // Mouse button event data
wheel: MouseWheelEvent, // Mouse wheel event data
jdevice: JoyDeviceEvent, // Joystick device change event data
jaxis: JoyAxisEvent, // Joystick axis event data
jball: JoyBallEvent, // Joystick ball event data
jhat: JoyHatEvent, // Joystick hat event data
jbutton: JoyButtonEvent, // Joystick button event data
jbattery: JoyBatteryEvent, // Joystick battery event data
gdevice: GamepadDeviceEvent, // Gamepad device event data
gaxis: GamepadAxisEvent, // Gamepad axis event data
gbutton: GamepadButtonEvent, // Gamepad button event data
gtouchpad: GamepadTouchpadEvent, // Gamepad touchpad event data
gsensor: GamepadSensorEvent, // Gamepad sensor event data
adevice: AudioDeviceEvent, // Audio device event data
cdevice: CameraDeviceEvent, // Camera device event data
sensor: SensorEvent, // Sensor event data
quit: QuitEvent, // Quit request event data
user: UserEvent, // Custom event data
tfinger: TouchFingerEvent, // Touch finger event data
pproximity: PenProximityEvent, // Pen proximity event data
ptouch: PenTouchEvent, // Pen tip touching event data
pmotion: PenMotionEvent, // Pen motion event data
pbutton: PenButtonEvent, // Pen button event data
paxis: PenAxisEvent, // Pen axis event data
render: RenderEvent, // Render event data
drop: DropEvent, // Drag and drop event data
clipboard: ClipboardEvent, // Clipboard event data
padding: [128]u8,
};
pub const InitFlags = packed struct(u32) {
pad0: u31 = 0,
rsvd: bool = false,
};
pub const AppInit_func = *const fn(appstate: [*c]?*anyopaque, argc: c_int, argv[]: [*c]u8) callconv(.C) AppResult;
pub const AppIterate_func = *const fn(appstate: ?*anyopaque) callconv(.C) AppResult;
pub const AppEvent_func = *const fn(appstate: ?*anyopaque, event: ?*Event) callconv(.C) AppResult;
pub const AppQuit_func = *const fn(appstate: ?*anyopaque, result: AppResult) callconv(.C) void;
pub inline fn init(flags: InitFlags) bool {
return c.SDL_Init(@bitCast(flags));
}
pub inline fn initSubSystem(flags: InitFlags) bool {
return c.SDL_InitSubSystem(@bitCast(flags));
}
pub inline fn quitSubSystem(flags: InitFlags) void {
return c.SDL_QuitSubSystem(@bitCast(flags));
}
pub inline fn wasInit(flags: InitFlags) InitFlags {
return @bitCast(c.SDL_WasInit(@bitCast(flags)));
}
pub inline fn quit() void {
return c.SDL_Quit();
}
pub inline fn isMainThread() bool {
return c.SDL_IsMainThread();
}
pub const MainThreadCallback = *const fn(userdata: ?*anyopaque) callconv(.C) void;
pub inline fn runOnMainThread(callback: MainThreadCallback, userdata: ?*anyopaque, wait_complete: bool) bool {
return c.SDL_RunOnMainThread(callback, userdata, wait_complete);
}
pub inline fn setAppMetadata(appname: [*c]const u8, appversion: [*c]const u8, appidentifier: [*c]const u8) bool {
return c.SDL_SetAppMetadata(appname, appversion, appidentifier);
}
pub inline fn setAppMetadataProperty(name: [*c]const u8, value: [*c]const u8) bool {
return c.SDL_SetAppMetadataProperty(name, value);
}
pub inline fn getAppMetadataProperty(name: [*c]const u8) [*c]const u8 {
return c.SDL_GetAppMetadataProperty(name);
}

210
lib/sdl3/v2/iostream.zig vendored Normal file
View File

@ -0,0 +1,210 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const PropertiesID = u32;
pub const IOStreamInterface = extern struct {
version: u32,
userdata: Sint64 (SDLCALL *size)(void *,
whence: Sint64 (SDLCALL *seek)(void *userdata, Sint64 offset, SDL_IOWhence,
status: size_t (SDLCALL *read)(void *userdata, void *ptr, size_t size, SDL_IOStatus *,
status: size_t (SDLCALL *write)(void *userdata, const void *ptr, size_t size, SDL_IOStatus *,
status: bool (SDLCALL *flush)(void *userdata, SDL_IOStatus *,
userdata: bool (SDLCALL *close)(void *,
};
pub const IOStream = opaque {
pub inline fn closeIO(iostream: *IOStream) bool {
return c.SDL_CloseIO(iostream);
}
pub inline fn getIOProperties(iostream: *IOStream) PropertiesID {
return c.SDL_GetIOProperties(iostream);
}
pub inline fn getIOStatus(iostream: *IOStream) IOStatus {
return c.SDL_GetIOStatus(iostream);
}
pub inline fn getIOSize(iostream: *IOStream) i64 {
return c.SDL_GetIOSize(iostream);
}
pub inline fn seekIO(iostream: *IOStream, offset: i64, whence: IOWhence) i64 {
return c.SDL_SeekIO(iostream, offset, whence);
}
pub inline fn tellIO(iostream: *IOStream) i64 {
return c.SDL_TellIO(iostream);
}
pub inline fn readIO(iostream: *IOStream, ptr: ?*anyopaque, size: usize) usize {
return c.SDL_ReadIO(iostream, ptr, size);
}
pub inline fn writeIO(iostream: *IOStream, ptr: ?*const anyopaque, size: usize) usize {
return c.SDL_WriteIO(iostream, ptr, size);
}
pub inline fn iOprintf(iostream: *IOStream, fmt: [*c]const u8, ...) usize {
return c.SDL_IOprintf(iostream, fmt, );
}
pub inline fn iOvprintf(iostream: *IOStream, fmt: [*c]const u8, ap: std.builtin.VaList) usize {
return c.SDL_IOvprintf(iostream, fmt, ap);
}
pub inline fn flushIO(iostream: *IOStream) bool {
return c.SDL_FlushIO(iostream);
}
pub inline fn loadFile_IO(iostream: *IOStream, datasize: *usize, closeio: bool) ?*anyopaque {
return c.SDL_LoadFile_IO(iostream, @ptrCast(datasize), closeio);
}
pub inline fn saveFile_IO(iostream: *IOStream, data: ?*const anyopaque, datasize: usize, closeio: bool,) bool {
return c.SDL_SaveFile_IO(iostream, data, datasize, closeio);
}
pub inline fn readU8(iostream: *IOStream, value: [*c]u8) bool {
return c.SDL_ReadU8(iostream, value);
}
pub inline fn readS8(iostream: *IOStream, value: Sint8 *) bool {
return c.SDL_ReadS8(iostream, value);
}
pub inline fn readU16LE(iostream: *IOStream, value: Uint16 *) bool {
return c.SDL_ReadU16LE(iostream, value);
}
pub inline fn readS16LE(iostream: *IOStream, value: Sint16 *) bool {
return c.SDL_ReadS16LE(iostream, value);
}
pub inline fn readU16BE(iostream: *IOStream, value: Uint16 *) bool {
return c.SDL_ReadU16BE(iostream, value);
}
pub inline fn readS16BE(iostream: *IOStream, value: Sint16 *) bool {
return c.SDL_ReadS16BE(iostream, value);
}
pub inline fn readU32LE(iostream: *IOStream, value: *u32) bool {
return c.SDL_ReadU32LE(iostream, @ptrCast(value));
}
pub inline fn readS32LE(iostream: *IOStream, value: *i32) bool {
return c.SDL_ReadS32LE(iostream, @ptrCast(value));
}
pub inline fn readU32BE(iostream: *IOStream, value: *u32) bool {
return c.SDL_ReadU32BE(iostream, @ptrCast(value));
}
pub inline fn readS32BE(iostream: *IOStream, value: *i32) bool {
return c.SDL_ReadS32BE(iostream, @ptrCast(value));
}
pub inline fn readU64LE(iostream: *IOStream, value: *u64) bool {
return c.SDL_ReadU64LE(iostream, @ptrCast(value));
}
pub inline fn readS64LE(iostream: *IOStream, value: Sint64 *) bool {
return c.SDL_ReadS64LE(iostream, value);
}
pub inline fn readU64BE(iostream: *IOStream, value: *u64) bool {
return c.SDL_ReadU64BE(iostream, @ptrCast(value));
}
pub inline fn readS64BE(iostream: *IOStream, value: Sint64 *) bool {
return c.SDL_ReadS64BE(iostream, value);
}
pub inline fn writeU8(iostream: *IOStream, value: u8) bool {
return c.SDL_WriteU8(iostream, value);
}
pub inline fn writeS8(iostream: *IOStream, value: i8) bool {
return c.SDL_WriteS8(iostream, value);
}
pub inline fn writeU16LE(iostream: *IOStream, value: u16) bool {
return c.SDL_WriteU16LE(iostream, value);
}
pub inline fn writeS16LE(iostream: *IOStream, value: i16) bool {
return c.SDL_WriteS16LE(iostream, value);
}
pub inline fn writeU16BE(iostream: *IOStream, value: u16) bool {
return c.SDL_WriteU16BE(iostream, value);
}
pub inline fn writeS16BE(iostream: *IOStream, value: i16) bool {
return c.SDL_WriteS16BE(iostream, value);
}
pub inline fn writeU32LE(iostream: *IOStream, value: u32) bool {
return c.SDL_WriteU32LE(iostream, value);
}
pub inline fn writeS32LE(iostream: *IOStream, value: i32) bool {
return c.SDL_WriteS32LE(iostream, value);
}
pub inline fn writeU32BE(iostream: *IOStream, value: u32) bool {
return c.SDL_WriteU32BE(iostream, value);
}
pub inline fn writeS32BE(iostream: *IOStream, value: i32) bool {
return c.SDL_WriteS32BE(iostream, value);
}
pub inline fn writeU64LE(iostream: *IOStream, value: u64) bool {
return c.SDL_WriteU64LE(iostream, value);
}
pub inline fn writeS64LE(iostream: *IOStream, value: i64) bool {
return c.SDL_WriteS64LE(iostream, value);
}
pub inline fn writeU64BE(iostream: *IOStream, value: u64) bool {
return c.SDL_WriteU64BE(iostream, value);
}
pub inline fn writeS64BE(iostream: *IOStream, value: i64) bool {
return c.SDL_WriteS64BE(iostream, value);
}
};
pub inline fn ioFromFile(file: [*c]const u8, mode: [*c]const u8) ?*IOStream {
return c.SDL_IOFromFile(file, mode);
}
pub inline fn ioFromMem(mem: ?*anyopaque, size: usize) ?*IOStream {
return c.SDL_IOFromMem(mem, size);
}
pub inline fn ioFromConstMem(mem: ?*const anyopaque, size: usize) ?*IOStream {
return c.SDL_IOFromConstMem(mem, size);
}
pub inline fn ioFromDynamicMem() ?*IOStream {
return c.SDL_IOFromDynamicMem();
}
pub inline fn openIO(iface: *const IOStreamInterface, userdata: ?*anyopaque) ?*IOStream {
return c.SDL_OpenIO(@ptrCast(iface), userdata);
}
pub inline fn loadFile(file: [*c]const u8, datasize: *usize) ?*anyopaque {
return c.SDL_LoadFile(file, @ptrCast(datasize));
}
pub inline fn saveFile(file: [*c]const u8, data: ?*const anyopaque, datasize: usize) bool {
return c.SDL_SaveFile(file, data, datasize);
}

View File

@ -292,10 +292,6 @@ pub inline fn getKeyFromName(name: [*c]const u8) Keycode {
return c.SDL_GetKeyFromName(name);
}
pub const TextInputType = enum(c_int) {};
pub const Capitalization = enum(c_int) {};
pub inline fn hasScreenKeyboardSupport() bool {
return c.SDL_HasScreenKeyboardSupport();
}

6
lib/sdl3/v2/keycode.zig vendored Normal file
View File

@ -0,0 +1,6 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const Keycode = u32;
pub const Keymod = u16;

117
lib/sdl3/v2/mouse.zig vendored Normal file
View File

@ -0,0 +1,117 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const Window = opaque {
pub inline fn warpMouseInWindow(window: *Window, x: f32, y: f32) void {
return c.SDL_WarpMouseInWindow(window, x, y);
}
pub inline fn setWindowRelativeMouseMode(window: *Window, enabled: bool) bool {
return c.SDL_SetWindowRelativeMouseMode(window, enabled);
}
pub inline fn getWindowRelativeMouseMode(window: *Window) bool {
return c.SDL_GetWindowRelativeMouseMode(window);
}
};
pub const Surface = opaque {
pub inline fn createColorCursor(surface: *Surface, hot_x: c_int, hot_y: c_int) ?*Cursor {
return c.SDL_CreateColorCursor(surface, hot_x, hot_y);
}
};
pub const MouseID = u32;
pub const Cursor = opaque {
pub inline fn setCursor(cursor: *Cursor) bool {
return c.SDL_SetCursor(cursor);
}
pub inline fn destroyCursor(cursor: *Cursor) void {
return c.SDL_DestroyCursor(cursor);
}
};
pub const SystemCursor = enum(c_int) {
systemCursorCount,
};
pub const MouseButtonFlags = packed struct(u32) {
buttonLeft: bool = false,
buttonMiddle: bool = false,
buttonX1: bool = false,
pad0: u28 = 0,
rsvd: bool = false,
};
pub inline fn hasMouse() bool {
return c.SDL_HasMouse();
}
pub inline fn getMice(count: *c_int) ?*MouseID {
return c.SDL_GetMice(@ptrCast(count));
}
pub inline fn getMouseNameForID(instance_id: MouseID) [*c]const u8 {
return c.SDL_GetMouseNameForID(instance_id);
}
pub inline fn getMouseFocus() ?*Window {
return c.SDL_GetMouseFocus();
}
pub inline fn getMouseState(x: *f32, y: *f32) MouseButtonFlags {
return @bitCast(c.SDL_GetMouseState(@ptrCast(x), @ptrCast(y)));
}
pub inline fn getGlobalMouseState(x: *f32, y: *f32) MouseButtonFlags {
return @bitCast(c.SDL_GetGlobalMouseState(@ptrCast(x), @ptrCast(y)));
}
pub inline fn getRelativeMouseState(x: *f32, y: *f32) MouseButtonFlags {
return @bitCast(c.SDL_GetRelativeMouseState(@ptrCast(x), @ptrCast(y)));
}
pub inline fn warpMouseGlobal(x: f32, y: f32) bool {
return c.SDL_WarpMouseGlobal(x, y);
}
pub inline fn captureMouse(enabled: bool) bool {
return c.SDL_CaptureMouse(enabled);
}
pub inline fn createCursor(
data: [*c]const u8,
mask: [*c]const u8,
w: c_int,
h: c_int,
hot_x: c_int,
hot_y: c_int,
) ?*Cursor {
return c.SDL_CreateCursor(data, mask, w, h, hot_x, hot_y);
}
pub inline fn createSystemCursor(id: SystemCursor) ?*Cursor {
return c.SDL_CreateSystemCursor(id);
}
pub inline fn getCursor() ?*Cursor {
return c.SDL_GetCursor();
}
pub inline fn getDefaultCursor() ?*Cursor {
return c.SDL_GetDefaultCursor();
}
pub inline fn showCursor() bool {
return c.SDL_ShowCursor();
}
pub inline fn hideCursor() bool {
return c.SDL_HideCursor();
}
pub inline fn cursorVisible() bool {
return c.SDL_CursorVisible();
}

292
lib/sdl3/v2/pixels.zig vendored Normal file
View File

@ -0,0 +1,292 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const PixelType = enum(c_int) {
pixeltypeUnknown,
pixeltypeIndex1,
pixeltypeIndex4,
pixeltypeIndex8,
pixeltypePacked8,
pixeltypePacked16,
pixeltypePacked32,
pixeltypeArrayu8,
pixeltypeArrayu16,
pixeltypeArrayu32,
pixeltypeArrayf16,
pixeltypeArrayf32,
pixeltypeIndex2,
};
pub const BitmapOrder = enum(c_int) {
bitmaporderNone,
bitmaporder4321,
bitmaporder1234,
};
pub const PackedOrder = enum(c_int) {
packedorderNone,
packedorderXrgb,
packedorderRgbx,
packedorderArgb,
packedorderRgba,
packedorderXbgr,
packedorderBgrx,
packedorderAbgr,
packedorderBgra,
};
pub const ArrayOrder = enum(c_int) {
arrayorderNone,
arrayorderRgb,
arrayorderRgba,
arrayorderArgb,
arrayorderBgr,
arrayorderBgra,
arrayorderAbgr,
};
pub const PackedLayout = enum(c_int) {
packedlayoutNone,
packedlayout332,
packedlayout4444,
packedlayout1555,
packedlayout5551,
packedlayout565,
packedlayout8888,
packedlayout2101010,
packedlayout1010102,
};
pub const PixelFormat = enum(c_int) {
pixelformatUnknown,
pixelformatIndex1lsb,
pixelformatIndex1msb,
pixelformatIndex2lsb,
pixelformatIndex2msb,
pixelformatIndex4lsb,
pixelformatIndex4msb,
pixelformatIndex8,
pixelformatRgb332,
pixelformatXrgb4444,
pixelformatXbgr4444,
pixelformatXrgb1555,
pixelformatXbgr1555,
pixelformatArgb4444,
pixelformatRgba4444,
pixelformatAbgr4444,
pixelformatBgra4444,
pixelformatArgb1555,
pixelformatRgba5551,
pixelformatAbgr1555,
pixelformatBgra5551,
pixelformatRgb565,
pixelformatBgr565,
pixelformatRgb24,
pixelformatBgr24,
pixelformatXrgb8888,
pixelformatRgbx8888,
pixelformatXbgr8888,
pixelformatBgrx8888,
pixelformatArgb8888,
pixelformatRgba8888,
pixelformatAbgr8888,
pixelformatBgra8888,
pixelformatXrgb2101010,
pixelformatXbgr2101010,
pixelformatArgb2101010,
pixelformatAbgr2101010,
pixelformatRgb48,
pixelformatBgr48,
pixelformatRgba64,
pixelformatArgb64,
pixelformatBgra64,
pixelformatAbgr64,
pixelformatRgb48Float,
pixelformatBgr48Float,
pixelformatRgba64Float,
pixelformatArgb64Float,
pixelformatBgra64Float,
pixelformatAbgr64Float,
pixelformatRgb96Float,
pixelformatBgr96Float,
pixelformatRgba128Float,
pixelformatArgb128Float,
pixelformatBgra128Float,
pixelformatAbgr128Float,
pixelformatRgba32,
pixelformatArgb32,
pixelformatBgra32,
pixelformatAbgr32,
pixelformatRgbx32,
pixelformatXrgb32,
pixelformatBgrx32,
pixelformatXbgr32,
};
pub const ColorType = enum(c_int) {
colorTypeUnknown,
colorTypeRgb,
colorTypeYcbcr,
};
pub const ColorRange = enum(c_int) {
colorRangeUnknown,
};
pub const ColorPrimaries = enum(c_int) {
colorPrimariesUnknown,
colorPrimariesUnspecified,
colorPrimariesCustom,
};
pub const TransferCharacteristics = enum(c_int) {
transferCharacteristicsUnknown,
transferCharacteristicsUnspecified,
transferCharacteristicsLinear,
transferCharacteristicsLog100,
transferCharacteristicsLog100Sqrt10,
transferCharacteristicsCustom,
};
pub const MatrixCoefficients = enum(c_int) {
matrixCoefficientsIdentity,
matrixCoefficientsUnspecified,
matrixCoefficientsYcgco,
matrixCoefficientsChromaDerivedNcl,
matrixCoefficientsChromaDerivedCl,
matrixCoefficientsCustom,
};
pub const Colorspace = enum(c_int) {
colorspaceUnknown,
};
pub const Color = extern struct {
r: u8,
g: u8,
b: u8,
a: u8,
};
pub const FColor = extern struct {
r: f32,
g: f32,
b: f32,
a: f32,
};
pub const Palette = extern struct {
ncolors: c_int, // number of elements in `colors`.
colors: ?*Color, // an array of colors, `ncolors` long.
version: u32, // internal use only, do not touch.
refcount: c_int, // internal use only, do not touch.
};
pub const PixelFormatDetails = extern struct {
format: PixelFormat,
bits_per_pixel: u8,
bytes_per_pixel: u8,
padding: [2]u8,
Rmask: u32,
Gmask: u32,
Bmask: u32,
Amask: u32,
Rbits: u8,
Gbits: u8,
Bbits: u8,
Abits: u8,
Rshift: u8,
Gshift: u8,
Bshift: u8,
Ashift: u8,
};
pub inline fn getPixelFormatName(format: PixelFormat) [*c]const u8 {
return c.SDL_GetPixelFormatName(@bitCast(format));
}
pub inline fn getMasksForPixelFormat(
format: PixelFormat,
bpp: *c_int,
Rmask: *u32,
Gmask: *u32,
Bmask: *u32,
Amask: *u32,
) bool {
return c.SDL_GetMasksForPixelFormat(@bitCast(format), @ptrCast(bpp), @ptrCast(Rmask), @ptrCast(Gmask), @ptrCast(Bmask), @ptrCast(Amask));
}
pub inline fn getPixelFormatForMasks(
bpp: c_int,
Rmask: u32,
Gmask: u32,
Bmask: u32,
Amask: u32,
) PixelFormat {
return @bitCast(c.SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask));
}
pub inline fn getPixelFormatDetails(format: PixelFormat) *const PixelFormatDetails {
return @ptrCast(c.SDL_GetPixelFormatDetails(@bitCast(format)));
}
pub inline fn createPalette(ncolors: c_int) ?*Palette {
return c.SDL_CreatePalette(ncolors);
}
pub inline fn setPaletteColors(
palette: ?*Palette,
colors: *const Color,
firstcolor: c_int,
ncolors: c_int,
) bool {
return c.SDL_SetPaletteColors(palette, @ptrCast(colors), firstcolor, ncolors);
}
pub inline fn destroyPalette(palette: ?*Palette) void {
return c.SDL_DestroyPalette(palette);
}
pub inline fn mapRGB(
format: *const PixelFormatDetails,
palette: *const Palette,
r: u8,
g: u8,
b: u8,
) u32 {
return c.SDL_MapRGB(@ptrCast(format), @ptrCast(palette), r, g, b);
}
pub inline fn mapRGBA(
format: *const PixelFormatDetails,
palette: *const Palette,
r: u8,
g: u8,
b: u8,
a: u8,
) u32 {
return c.SDL_MapRGBA(@ptrCast(format), @ptrCast(palette), r, g, b, a);
}
pub inline fn getRGB(
pixel: u32,
format: *const PixelFormatDetails,
palette: *const Palette,
r: [*c]u8,
g: [*c]u8,
b: [*c]u8,
) void {
return c.SDL_GetRGB(pixel, @ptrCast(format), @ptrCast(palette), r, g, b);
}
pub inline fn getRGBA(
pixel: u32,
format: *const PixelFormatDetails,
palette: *const Palette,
r: [*c]u8,
g: [*c]u8,
b: [*c]u8,
a: [*c]u8,
) void {
return c.SDL_GetRGBA(pixel, @ptrCast(format), @ptrCast(palette), r, g, b, a);
}

88
lib/sdl3/v2/rect.zig vendored Normal file
View File

@ -0,0 +1,88 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const Point = extern struct {
x: c_int,
y: c_int,
};
pub const FPoint = extern struct {
x: f32,
y: f32,
};
pub const Rect = extern struct {
x: c_int,
y: c_int,
w: c_int,
h: c_int,
};
pub const FRect = extern struct {
x: f32,
y: f32,
w: f32,
h: f32,
};
pub inline fn hasRectIntersection(A: *const Rect, B: *const Rect) bool {
return c.SDL_HasRectIntersection(@ptrCast(A), @ptrCast(B));
}
pub inline fn getRectIntersection(A: *const Rect, B: *const Rect, result: ?*Rect) bool {
return c.SDL_GetRectIntersection(@ptrCast(A), @ptrCast(B), result);
}
pub inline fn getRectUnion(A: *const Rect, B: *const Rect, result: ?*Rect) bool {
return c.SDL_GetRectUnion(@ptrCast(A), @ptrCast(B), result);
}
pub inline fn getRectEnclosingPoints(
points: *const Point,
count: c_int,
clip: *const Rect,
result: ?*Rect,
) bool {
return c.SDL_GetRectEnclosingPoints(@ptrCast(points), count, @ptrCast(clip), result);
}
pub inline fn getRectAndLineIntersection(
rect: *const Rect,
X1: *c_int,
Y1: *c_int,
X2: *c_int,
Y2: *c_int,
) bool {
return c.SDL_GetRectAndLineIntersection(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2));
}
pub inline fn hasRectIntersectionFloat(A: *const FRect, B: *const FRect) bool {
return c.SDL_HasRectIntersectionFloat(@ptrCast(A), @ptrCast(B));
}
pub inline fn getRectIntersectionFloat(A: *const FRect, B: *const FRect, result: ?*FRect) bool {
return c.SDL_GetRectIntersectionFloat(@ptrCast(A), @ptrCast(B), result);
}
pub inline fn getRectUnionFloat(A: *const FRect, B: *const FRect, result: ?*FRect) bool {
return c.SDL_GetRectUnionFloat(@ptrCast(A), @ptrCast(B), result);
}
pub inline fn getRectEnclosingPointsFloat(
points: *const FPoint,
count: c_int,
clip: *const FRect,
result: ?*FRect,
) bool {
return c.SDL_GetRectEnclosingPointsFloat(@ptrCast(points), count, @ptrCast(clip), result);
}
pub inline fn getRectAndLineIntersectionFloat(
rect: *const FRect,
X1: *f32,
Y1: *f32,
X2: *f32,
Y2: *f32,
) bool {
return c.SDL_GetRectAndLineIntersectionFloat(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2));
}

184
lib/sdl3/v2/scancode.zig vendored Normal file
View File

@ -0,0 +1,184 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const Scancode = enum(c_int) {
scancodeUnknown,
scancodeA,
scancodeB,
scancodeC,
scancodeD,
scancodeE,
scancodeF,
scancodeG,
scancodeH,
scancodeI,
scancodeJ,
scancodeK,
scancodeL,
scancodeM,
scancodeN,
scancodeO,
scancodeP,
scancodeQ,
scancodeR,
scancodeS,
scancodeT,
scancodeU,
scancodeV,
scancodeW,
scancodeX,
scancodeY,
scancodeZ,
scancode1,
scancode2,
scancode3,
scancode4,
scancode5,
scancode6,
scancode7,
scancode8,
scancode9,
scancode0,
scancodeReturn,
scancodeEscape,
scancodeBackspace,
scancodeTab,
scancodeSpace,
scancodeMinus,
scancodeEquals,
scancodeLeftbracket,
scancodeRightbracket,
scancodeSemicolon,
scancodeApostrophe,
scancodeComma,
scancodePeriod,
scancodeSlash,
scancodeCapslock,
scancodeF1,
scancodeF2,
scancodeF3,
scancodeF4,
scancodeF5,
scancodeF6,
scancodeF7,
scancodeF8,
scancodeF9,
scancodeF10,
scancodeF11,
scancodeF12,
scancodePrintscreen,
scancodeScrolllock,
scancodePause,
scancodeHome,
scancodePageup,
scancodeDelete,
scancodeEnd,
scancodePagedown,
scancodeRight,
scancodeLeft,
scancodeDown,
scancodeUp,
scancodeKpDivide,
scancodeKpMultiply,
scancodeKpMinus,
scancodeKpPlus,
scancodeKpEnter,
scancodeKp1,
scancodeKp2,
scancodeKp3,
scancodeKp4,
scancodeKp5,
scancodeKp6,
scancodeKp7,
scancodeKp8,
scancodeKp9,
scancodeKp0,
scancodeKpPeriod,
scancodeKpEquals,
scancodeF13,
scancodeF14,
scancodeF15,
scancodeF16,
scancodeF17,
scancodeF18,
scancodeF19,
scancodeF20,
scancodeF21,
scancodeF22,
scancodeF23,
scancodeF24,
scancodeExecute,
scancodeSelect,
scancodeMute,
scancodeVolumeup,
scancodeVolumedown,
scancodeKpComma,
scancodeKpEqualsas400,
scancodeInternational2,
scancodeInternational4,
scancodeInternational5,
scancodeInternational6,
scancodeInternational7,
scancodeInternational8,
scancodeInternational9,
scancodeSysreq,
scancodeClear,
scancodePrior,
scancodeReturn2,
scancodeSeparator,
scancodeOut,
scancodeOper,
scancodeClearagain,
scancodeCrsel,
scancodeExsel,
scancodeKp00,
scancodeKp000,
scancodeThousandsseparator,
scancodeDecimalseparator,
scancodeCurrencyunit,
scancodeCurrencysubunit,
scancodeKpLeftparen,
scancodeKpRightparen,
scancodeKpLeftbrace,
scancodeKpRightbrace,
scancodeKpTab,
scancodeKpBackspace,
scancodeKpA,
scancodeKpB,
scancodeKpC,
scancodeKpD,
scancodeKpE,
scancodeKpF,
scancodeKpXor,
scancodeKpPower,
scancodeKpPercent,
scancodeKpLess,
scancodeKpGreater,
scancodeKpAmpersand,
scancodeKpDblampersand,
scancodeKpVerticalbar,
scancodeKpDblverticalbar,
scancodeKpColon,
scancodeKpHash,
scancodeKpSpace,
scancodeKpAt,
scancodeKpExclam,
scancodeKpMemstore,
scancodeKpMemrecall,
scancodeKpMemclear,
scancodeKpMemadd,
scancodeKpMemsubtract,
scancodeKpMemmultiply,
scancodeKpMemdivide,
scancodeKpPlusminus,
scancodeKpClear,
scancodeKpClearentry,
scancodeKpBinary,
scancodeKpOctal,
scancodeKpDecimal,
scancodeKpHexadecimal,
scancodeLctrl,
scancodeLshift,
scancodeRctrl,
scancodeRshift,
};

499
lib/sdl3/v2/surface.zig vendored Normal file
View File

@ -0,0 +1,499 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub const PixelFormat = enum(c_int) {
pixelformatUnknown,
pixelformatIndex1lsb,
pixelformatIndex1msb,
pixelformatIndex2lsb,
pixelformatIndex2msb,
pixelformatIndex4lsb,
pixelformatIndex4msb,
pixelformatIndex8,
pixelformatRgb332,
pixelformatXrgb4444,
pixelformatXbgr4444,
pixelformatXrgb1555,
pixelformatXbgr1555,
pixelformatArgb4444,
pixelformatRgba4444,
pixelformatAbgr4444,
pixelformatBgra4444,
pixelformatArgb1555,
pixelformatRgba5551,
pixelformatAbgr1555,
pixelformatBgra5551,
pixelformatRgb565,
pixelformatBgr565,
pixelformatRgb24,
pixelformatBgr24,
pixelformatXrgb8888,
pixelformatRgbx8888,
pixelformatXbgr8888,
pixelformatBgrx8888,
pixelformatArgb8888,
pixelformatRgba8888,
pixelformatAbgr8888,
pixelformatBgra8888,
pixelformatXrgb2101010,
pixelformatXbgr2101010,
pixelformatArgb2101010,
pixelformatAbgr2101010,
pixelformatRgb48,
pixelformatBgr48,
pixelformatRgba64,
pixelformatArgb64,
pixelformatBgra64,
pixelformatAbgr64,
pixelformatRgb48Float,
pixelformatBgr48Float,
pixelformatRgba64Float,
pixelformatArgb64Float,
pixelformatBgra64Float,
pixelformatAbgr64Float,
pixelformatRgb96Float,
pixelformatBgr96Float,
pixelformatRgba128Float,
pixelformatArgb128Float,
pixelformatBgra128Float,
pixelformatAbgr128Float,
pixelformatRgba32,
pixelformatArgb32,
pixelformatBgra32,
pixelformatAbgr32,
pixelformatRgbx32,
pixelformatXrgb32,
pixelformatBgrx32,
pixelformatXbgr32,
};
pub const BlendMode = u32;
pub const IOStream = opaque {
pub inline fn loadBMP_IO(iostream: *IOStream, closeio: bool) ?*Surface {
return c.SDL_LoadBMP_IO(iostream, closeio);
}
};
pub const Rect = extern struct {
x: c_int,
y: c_int,
w: c_int,
h: c_int,
};
pub const Palette = extern struct {
ncolors: c_int, // number of elements in `colors`.
colors: ?*Color, // an array of colors, `ncolors` long.
version: u32, // internal use only, do not touch.
refcount: c_int, // internal use only, do not touch.
};
pub const Colorspace = enum(c_int) {
colorspaceUnknown,
};
pub const PropertiesID = u32;
pub const SurfaceFlags = packed struct(u32) {
pad0: u31 = 0,
rsvd: bool = false,
};
pub const ScaleMode = enum(c_int) {
scalemodeInvalid,
};
pub const Surface = opaque {
pub inline fn destroySurface(surface: *Surface) void {
return c.SDL_DestroySurface(surface);
}
pub inline fn getSurfaceProperties(surface: *Surface) PropertiesID {
return c.SDL_GetSurfaceProperties(surface);
}
pub inline fn setSurfaceColorspace(surface: *Surface, colorspace: Colorspace) bool {
return c.SDL_SetSurfaceColorspace(surface, colorspace);
}
pub inline fn getSurfaceColorspace(surface: *Surface) Colorspace {
return c.SDL_GetSurfaceColorspace(surface);
}
pub inline fn createSurfacePalette(surface: *Surface) ?*Palette {
return c.SDL_CreateSurfacePalette(surface);
}
pub inline fn setSurfacePalette(surface: *Surface, palette: ?*Palette) bool {
return c.SDL_SetSurfacePalette(surface, palette);
}
pub inline fn getSurfacePalette(surface: *Surface) ?*Palette {
return c.SDL_GetSurfacePalette(surface);
}
pub inline fn addSurfaceAlternateImage(surface: *Surface, image: ?*Surface) bool {
return c.SDL_AddSurfaceAlternateImage(surface, image);
}
pub inline fn surfaceHasAlternateImages(surface: *Surface) bool {
return c.SDL_SurfaceHasAlternateImages(surface);
}
pub inline fn getSurfaceImages(surface: *Surface, count: *c_int) ?*?*Surface {
return c.SDL_GetSurfaceImages(surface, @ptrCast(count));
}
pub inline fn removeSurfaceAlternateImages(surface: *Surface) void {
return c.SDL_RemoveSurfaceAlternateImages(surface);
}
pub inline fn lockSurface(surface: *Surface) bool {
return c.SDL_LockSurface(surface);
}
pub inline fn unlockSurface(surface: *Surface) void {
return c.SDL_UnlockSurface(surface);
}
pub inline fn saveBMP_IO(surface: *Surface, dst: ?*IOStream, closeio: bool) bool {
return c.SDL_SaveBMP_IO(surface, dst, closeio);
}
pub inline fn saveBMP(surface: *Surface, file: [*c]const u8) bool {
return c.SDL_SaveBMP(surface, file);
}
pub inline fn setSurfaceRLE(surface: *Surface, enabled: bool) bool {
return c.SDL_SetSurfaceRLE(surface, enabled);
}
pub inline fn surfaceHasRLE(surface: *Surface) bool {
return c.SDL_SurfaceHasRLE(surface);
}
pub inline fn setSurfaceColorKey(surface: *Surface, enabled: bool, key: u32) bool {
return c.SDL_SetSurfaceColorKey(surface, enabled, key);
}
pub inline fn surfaceHasColorKey(surface: *Surface) bool {
return c.SDL_SurfaceHasColorKey(surface);
}
pub inline fn getSurfaceColorKey(surface: *Surface, key: *u32) bool {
return c.SDL_GetSurfaceColorKey(surface, @ptrCast(key));
}
pub inline fn setSurfaceColorMod(
surface: *Surface,
r: u8,
g: u8,
b: u8,
) bool {
return c.SDL_SetSurfaceColorMod(surface, r, g, b);
}
pub inline fn getSurfaceColorMod(
surface: *Surface,
r: [*c]u8,
g: [*c]u8,
b: [*c]u8,
) bool {
return c.SDL_GetSurfaceColorMod(surface, r, g, b);
}
pub inline fn setSurfaceAlphaMod(surface: *Surface, alpha: u8) bool {
return c.SDL_SetSurfaceAlphaMod(surface, alpha);
}
pub inline fn getSurfaceAlphaMod(surface: *Surface, alpha: [*c]u8) bool {
return c.SDL_GetSurfaceAlphaMod(surface, alpha);
}
pub inline fn setSurfaceBlendMode(surface: *Surface, blendMode: BlendMode) bool {
return c.SDL_SetSurfaceBlendMode(surface, @intFromEnum(blendMode));
}
pub inline fn getSurfaceBlendMode(surface: *Surface, blendMode: ?*BlendMode) bool {
return c.SDL_GetSurfaceBlendMode(surface, @intFromEnum(blendMode));
}
pub inline fn setSurfaceClipRect(surface: *Surface, rect: *const Rect) bool {
return c.SDL_SetSurfaceClipRect(surface, @ptrCast(rect));
}
pub inline fn getSurfaceClipRect(surface: *Surface, rect: ?*Rect) bool {
return c.SDL_GetSurfaceClipRect(surface, rect);
}
pub inline fn flipSurface(surface: *Surface, flip: FlipMode) bool {
return c.SDL_FlipSurface(surface, @intFromEnum(flip));
}
pub inline fn duplicateSurface(surface: *Surface) ?*Surface {
return c.SDL_DuplicateSurface(surface);
}
pub inline fn scaleSurface(
surface: *Surface,
width: c_int,
height: c_int,
scaleMode: ScaleMode,
) ?*Surface {
return c.SDL_ScaleSurface(surface, width, height, @intFromEnum(scaleMode));
}
pub inline fn convertSurface(surface: *Surface, format: PixelFormat) ?*Surface {
return c.SDL_ConvertSurface(surface, @bitCast(format));
}
pub inline fn convertSurfaceAndColorspace(
surface: *Surface,
format: PixelFormat,
palette: ?*Palette,
colorspace: Colorspace,
props: PropertiesID,
) ?*Surface {
return c.SDL_ConvertSurfaceAndColorspace(surface, @bitCast(format), palette, colorspace, props);
}
pub inline fn premultiplySurfaceAlpha(surface: *Surface, linear: bool) bool {
return c.SDL_PremultiplySurfaceAlpha(surface, linear);
}
pub inline fn clearSurface(
surface: *Surface,
r: f32,
g: f32,
b: f32,
a: f32,
) bool {
return c.SDL_ClearSurface(surface, r, g, b, a);
}
pub inline fn fillSurfaceRect(surface: *Surface, rect: *const Rect, color: u32) bool {
return c.SDL_FillSurfaceRect(surface, @ptrCast(rect), color);
}
pub inline fn fillSurfaceRects(
surface: *Surface,
rects: *const Rect,
count: c_int,
color: u32,
) bool {
return c.SDL_FillSurfaceRects(surface, @ptrCast(rects), count, color);
}
pub inline fn blitSurface(
surface: *Surface,
srcrect: *const Rect,
dst: ?*Surface,
dstrect: *const Rect,
) bool {
return c.SDL_BlitSurface(surface, @ptrCast(srcrect), dst, @ptrCast(dstrect));
}
pub inline fn blitSurfaceUnchecked(
surface: *Surface,
srcrect: *const Rect,
dst: ?*Surface,
dstrect: *const Rect,
) bool {
return c.SDL_BlitSurfaceUnchecked(surface, @ptrCast(srcrect), dst, @ptrCast(dstrect));
}
pub inline fn blitSurfaceScaled(
surface: *Surface,
srcrect: *const Rect,
dst: ?*Surface,
dstrect: *const Rect,
scaleMode: ScaleMode,
) bool {
return c.SDL_BlitSurfaceScaled(surface, @ptrCast(srcrect), dst, @ptrCast(dstrect), @intFromEnum(scaleMode));
}
pub inline fn blitSurfaceUncheckedScaled(
surface: *Surface,
srcrect: *const Rect,
dst: ?*Surface,
dstrect: *const Rect,
scaleMode: ScaleMode,
) bool {
return c.SDL_BlitSurfaceUncheckedScaled(surface, @ptrCast(srcrect), dst, @ptrCast(dstrect), @intFromEnum(scaleMode));
}
pub inline fn stretchSurface(
surface: *Surface,
srcrect: *const Rect,
dst: ?*Surface,
dstrect: *const Rect,
scaleMode: ScaleMode,
) bool {
return c.SDL_StretchSurface(surface, @ptrCast(srcrect), dst, @ptrCast(dstrect), @intFromEnum(scaleMode));
}
pub inline fn blitSurfaceTiled(
surface: *Surface,
srcrect: *const Rect,
dst: ?*Surface,
dstrect: *const Rect,
) bool {
return c.SDL_BlitSurfaceTiled(surface, @ptrCast(srcrect), dst, @ptrCast(dstrect));
}
pub inline fn blitSurfaceTiledWithScale(
surface: *Surface,
srcrect: *const Rect,
scale: f32,
scaleMode: ScaleMode,
dst: ?*Surface,
dstrect: *const Rect,
) bool {
return c.SDL_BlitSurfaceTiledWithScale(surface, @ptrCast(srcrect), scale, @intFromEnum(scaleMode), dst, @ptrCast(dstrect));
}
pub inline fn blitSurface9Grid(
surface: *Surface,
srcrect: *const Rect,
left_width: c_int,
right_width: c_int,
top_height: c_int,
bottom_height: c_int,
scale: f32,
scaleMode: ScaleMode,
dst: ?*Surface,
dstrect: *const Rect,
) bool {
return c.SDL_BlitSurface9Grid(surface, @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @intFromEnum(scaleMode), dst, @ptrCast(dstrect));
}
pub inline fn mapSurfaceRGB(
surface: *Surface,
r: u8,
g: u8,
b: u8,
) u32 {
return c.SDL_MapSurfaceRGB(surface, r, g, b);
}
pub inline fn mapSurfaceRGBA(
surface: *Surface,
r: u8,
g: u8,
b: u8,
a: u8,
) u32 {
return c.SDL_MapSurfaceRGBA(surface, r, g, b, a);
}
pub inline fn readSurfacePixel(
surface: *Surface,
x: c_int,
y: c_int,
r: [*c]u8,
g: [*c]u8,
b: [*c]u8,
a: [*c]u8,
) bool {
return c.SDL_ReadSurfacePixel(surface, x, y, r, g, b, a);
}
pub inline fn readSurfacePixelFloat(
surface: *Surface,
x: c_int,
y: c_int,
r: *f32,
g: *f32,
b: *f32,
a: *f32,
) bool {
return c.SDL_ReadSurfacePixelFloat(surface, x, y, @ptrCast(r), @ptrCast(g), @ptrCast(b), @ptrCast(a));
}
pub inline fn writeSurfacePixel(
surface: *Surface,
x: c_int,
y: c_int,
r: u8,
g: u8,
b: u8,
a: u8,
) bool {
return c.SDL_WriteSurfacePixel(surface, x, y, r, g, b, a);
}
pub inline fn writeSurfacePixelFloat(
surface: *Surface,
x: c_int,
y: c_int,
r: f32,
g: f32,
b: f32,
a: f32,
) bool {
return c.SDL_WriteSurfacePixelFloat(surface, x, y, r, g, b, a);
}
};
pub inline fn createSurface(width: c_int, height: c_int, format: PixelFormat) ?*Surface {
return c.SDL_CreateSurface(width, height, @bitCast(format));
}
pub inline fn createSurfaceFrom(
width: c_int,
height: c_int,
format: PixelFormat,
pixels: ?*anyopaque,
pitch: c_int,
) ?*Surface {
return c.SDL_CreateSurfaceFrom(width, height, @bitCast(format), pixels, pitch);
}
pub inline fn loadBMP(file: [*c]const u8) ?*Surface {
return c.SDL_LoadBMP(file);
}
pub inline fn convertPixels(
width: c_int,
height: c_int,
src_format: PixelFormat,
src: ?*const anyopaque,
src_pitch: c_int,
dst_format: PixelFormat,
dst: ?*anyopaque,
dst_pitch: c_int,
) bool {
return c.SDL_ConvertPixels(width, height, @bitCast(src_format), src, src_pitch, @bitCast(dst_format), dst, dst_pitch);
}
pub inline fn convertPixelsAndColorspace(
width: c_int,
height: c_int,
src_format: PixelFormat,
src_colorspace: Colorspace,
src_properties: PropertiesID,
src: ?*const anyopaque,
src_pitch: c_int,
dst_format: PixelFormat,
dst_colorspace: Colorspace,
dst_properties: PropertiesID,
dst: ?*anyopaque,
dst_pitch: c_int,
) bool {
return c.SDL_ConvertPixelsAndColorspace(width, height, @bitCast(src_format), src_colorspace, src_properties, src, src_pitch, @bitCast(dst_format), dst_colorspace, dst_properties, dst, dst_pitch);
}
pub inline fn premultiplyAlpha(
width: c_int,
height: c_int,
src_format: PixelFormat,
src: ?*const anyopaque,
src_pitch: c_int,
dst_format: PixelFormat,
dst: ?*anyopaque,
dst_pitch: c_int,
linear: bool,
) bool {
return c.SDL_PremultiplyAlpha(width, height, @bitCast(src_format), src, src_pitch, @bitCast(dst_format), dst, dst_pitch, linear);
}

48
lib/sdl3/v2/timer.zig vendored Normal file
View File

@ -0,0 +1,48 @@
const std = @import("std");
pub const c = @import("c.zig").c;
pub inline fn getTicks() u64 {
return c.SDL_GetTicks();
}
pub inline fn getTicksNS() u64 {
return c.SDL_GetTicksNS();
}
pub inline fn getPerformanceCounter() u64 {
return c.SDL_GetPerformanceCounter();
}
pub inline fn getPerformanceFrequency() u64 {
return c.SDL_GetPerformanceFrequency();
}
pub inline fn delay(ms: u32) void {
return c.SDL_Delay(ms);
}
pub inline fn delayNS(ns: u64) void {
return c.SDL_DelayNS(ns);
}
pub inline fn delayPrecise(ns: u64) void {
return c.SDL_DelayPrecise(ns);
}
pub const TimerID = u32;
pub const TimerCallback = *const fn (userdata: ?*anyopaque, timerID: TimerID, interval: u32) callconv(.C) u32;
pub inline fn addTimer(interval: u32, callback: TimerCallback, userdata: ?*anyopaque) TimerID {
return c.SDL_AddTimer(interval, callback, userdata);
}
pub const NSTimerCallback = *const fn (userdata: ?*anyopaque, timerID: TimerID, interval: u64) callconv(.C) u64;
pub inline fn addTimerNS(interval: u64, callback: NSTimerCallback, userdata: ?*anyopaque) TimerID {
return c.SDL_AddTimerNS(interval, callback, userdata);
}
pub inline fn removeTimer(id: TimerID) bool {
return c.SDL_RemoveTimer(id);
}

20
lib/sdl3/v2/video.zig vendored
View File

@ -87,13 +87,19 @@ pub const DisplayID = u32;
pub const WindowID = u32;
pub const SystemTheme = enum(c_int) {};
pub const DisplayModeData = opaque {};
pub const DisplayMode = extern struct {};
pub const DisplayOrientation = enum(c_int) {};
pub const DisplayMode = extern struct {
displayID: DisplayID, // the display this mode is associated with
format: PixelFormat, // pixel format
w: c_int, // width
h: c_int, // height
pixel_density: f32, // scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels)
refresh_rate: f32, // refresh rate (or 0.0f for unspecified)
refresh_rate_numerator: c_int, // precise refresh rate numerator (or 0 for unspecified)
refresh_rate_denominator: c_int, // precise refresh rate denominator
internal: ?*DisplayModeData, // Private
};
pub const Window = opaque {
pub inline fn getDisplayForWindow(window: *Window) DisplayID {
@ -404,8 +410,6 @@ pub const WindowFlags = packed struct(u64) {
rsvd: bool = false,
};
pub const FlashOperation = enum(c_int) {};
pub const GLContextState = extern struct {};
pub const GLProfile = u32;
@ -524,8 +528,6 @@ pub inline fn getGrabbedWindow() ?*Window {
return c.SDL_GetGrabbedWindow();
}
pub const HitTestResult = enum(c_int) {};
pub inline fn screenSaverEnabled() bool {
return c.SDL_ScreenSaverEnabled();
}