Add mutex to ignore list, keep only core SDL3 APIs

This commit is contained in:
Peterino2 2026-01-22 18:56:56 -08:00
parent e9fcd25c51
commit 83aa5fc26c
29 changed files with 187 additions and 760 deletions

10
lib/sdl3/build.zig vendored
View File

@ -144,8 +144,8 @@ pub fn build(b: *std.Build) void {
const parser_exe = parser_dep.artifact("sdl-parser");
// All public SDL3 API headers (53 total)
// Skipped: assert, thread, hidapi, mutex, tray (not core APIs or problematic)
const headers_to_generate = [_]struct { header: []const u8, output: []const u8 }{
.{ .header = "SDL/include/SDL3/SDL_assert.h", .output = "v2/assert.zig" },
.{ .header = "SDL/include/SDL3/SDL_asyncio.h", .output = "v2/asyncio.zig" },
.{ .header = "SDL/include/SDL3/SDL_atomic.h", .output = "v2/atomic.zig" },
.{ .header = "SDL/include/SDL3/SDL_audio.h", .output = "v2/audio.zig" },
@ -162,7 +162,7 @@ pub fn build(b: *std.Build) void {
.{ .header = "SDL/include/SDL3/SDL_gpu.h", .output = "v2/gpu.zig" },
.{ .header = "SDL/include/SDL3/SDL_guid.h", .output = "v2/guid.zig" },
.{ .header = "SDL/include/SDL3/SDL_haptic.h", .output = "v2/haptic.zig" },
.{ .header = "SDL/include/SDL3/SDL_hidapi.h", .output = "v2/hidapi.zig" },
// .{ .header = "SDL/include/SDL3/SDL_hidapi.h", .output = "v2/hidapi.zig" }, // Skipped: not core API
.{ .header = "SDL/include/SDL3/SDL_hints.h", .output = "v2/hints.zig" },
.{ .header = "SDL/include/SDL3/SDL_init.h", .output = "v2/init.zig" },
.{ .header = "SDL/include/SDL3/SDL_iostream.h", .output = "v2/iostream.zig" },
@ -176,7 +176,7 @@ pub fn build(b: *std.Build) void {
.{ .header = "SDL/include/SDL3/SDL_metal.h", .output = "v2/metal.zig" },
.{ .header = "SDL/include/SDL3/SDL_misc.h", .output = "v2/misc.zig" },
.{ .header = "SDL/include/SDL3/SDL_mouse.h", .output = "v2/mouse.zig" },
.{ .header = "SDL/include/SDL3/SDL_mutex.h", .output = "v2/mutex.zig" },
// .{ .header = "SDL/include/SDL3/SDL_mutex.h", .output = "v2/mutex.zig" }, // Skipped: not core API
.{ .header = "SDL/include/SDL3/SDL_opengl.h", .output = "v2/opengl.zig" },
.{ .header = "SDL/include/SDL3/SDL_pen.h", .output = "v2/pen.zig" },
.{ .header = "SDL/include/SDL3/SDL_pixels.h", .output = "v2/pixels.zig" },
@ -190,11 +190,11 @@ pub fn build(b: *std.Build) void {
.{ .header = "SDL/include/SDL3/SDL_storage.h", .output = "v2/storage.zig" },
.{ .header = "SDL/include/SDL3/SDL_surface.h", .output = "v2/surface.zig" },
.{ .header = "SDL/include/SDL3/SDL_system.h", .output = "v2/system.zig" },
.{ .header = "SDL/include/SDL3/SDL_thread.h", .output = "v2/thread.zig" },
// .{ .header = "SDL/include/SDL3/SDL_thread.h", .output = "v2/thread.zig" }, // Skipped: not core API
.{ .header = "SDL/include/SDL3/SDL_time.h", .output = "v2/time.zig" },
.{ .header = "SDL/include/SDL3/SDL_timer.h", .output = "v2/timer.zig" },
.{ .header = "SDL/include/SDL3/SDL_touch.h", .output = "v2/touch.zig" },
.{ .header = "SDL/include/SDL3/SDL_tray.h", .output = "v2/tray.zig" },
// .{ .header = "SDL/include/SDL3/SDL_tray.h", .output = "v2/tray.zig" }, // Skipped: not core API
.{ .header = "SDL/include/SDL3/SDL_version.h", .output = "v2/version.zig" },
.{ .header = "SDL/include/SDL3/SDL_video.h", .output = "v2/video.zig" },
.{ .header = "SDL/include/SDL3/SDL_vulkan.h", .output = "v2/vulkan.zig" },

View File

@ -11,7 +11,7 @@ pub const AssertData = extern struct {
next: const struct SDL_AssertData *, // next item in the linked list.
};
pub inline fn reportAssertion(data: ?*AssertData, func: [*c]const u8, file: [*c]const u8, line: c_int,) AssertState {
pub inline fn reportAssertion(data: ?*AssertData, func: [*c]const u8, file: [*c]const u8, line: c_int) AssertState {
return c.SDL_ReportAssertion(data, func, file, line);
}

View File

@ -6,34 +6,15 @@ pub const AsyncIO = opaque {
return c.SDL_GetAsyncIOSize(asyncio);
}
pub inline fn readAsyncIO(
asyncio: *AsyncIO,
ptr: ?*anyopaque,
offset: u64,
size: u64,
queue: ?*AsyncIOQueue,
userdata: ?*anyopaque,
) bool {
pub inline fn readAsyncIO(asyncio: *AsyncIO, ptr: ?*anyopaque, offset: u64, size: u64, queue: ?*AsyncIOQueue, userdata: ?*anyopaque) bool {
return c.SDL_ReadAsyncIO(asyncio, ptr, offset, size, queue, userdata);
}
pub inline fn writeAsyncIO(
asyncio: *AsyncIO,
ptr: ?*anyopaque,
offset: u64,
size: u64,
queue: ?*AsyncIOQueue,
userdata: ?*anyopaque,
) bool {
pub inline fn writeAsyncIO(asyncio: *AsyncIO, ptr: ?*anyopaque, offset: u64, size: u64, queue: ?*AsyncIOQueue, userdata: ?*anyopaque) bool {
return c.SDL_WriteAsyncIO(asyncio, ptr, offset, size, queue, userdata);
}
pub inline fn closeAsyncIO(
asyncio: *AsyncIO,
flush: bool,
queue: ?*AsyncIOQueue,
userdata: ?*anyopaque,
) bool {
pub inline fn closeAsyncIO(asyncio: *AsyncIO, flush: bool, queue: ?*AsyncIOQueue, userdata: ?*anyopaque) bool {
return c.SDL_CloseAsyncIO(asyncio, flush, queue, userdata);
}
};

10
lib/sdl3/v2/audio.zig vendored
View File

@ -4,7 +4,7 @@ pub const c = @import("c.zig").c;
pub const PropertiesID = u32;
pub const IOStream = opaque {
pub inline fn loadWAV_IO(iostream: *IOStream, closeio: bool, spec: ?*AudioSpec, audio_buf: Uint8 **, audio_len: *u32,) bool {
pub inline fn loadWAV_IO(iostream: *IOStream, closeio: bool, spec: ?*AudioSpec, audio_buf: Uint8 **, audio_len: *u32) bool {
return c.SDL_LoadWAV_IO(iostream, closeio, spec, audio_buf, @ptrCast(audio_len));
}
@ -221,7 +221,7 @@ pub inline fn createAudioStream(src_spec: *const AudioSpec, dst_spec: *const Aud
pub const AudioStreamCallback = *const fn(userdata: ?*anyopaque, stream: ?*AudioStream, additional_amount: c_int, total_amount: c_int) callconv(.C) void;
pub inline fn openAudioDeviceStream(devid: AudioDeviceID, spec: *const AudioSpec, callback: AudioStreamCallback, userdata: ?*anyopaque,) ?*AudioStream {
pub inline fn openAudioDeviceStream(devid: AudioDeviceID, spec: *const AudioSpec, callback: AudioStreamCallback, userdata: ?*anyopaque) ?*AudioStream {
return c.SDL_OpenAudioDeviceStream(devid, @ptrCast(spec), callback, userdata);
}
@ -231,15 +231,15 @@ pub inline fn setAudioPostmixCallback(devid: AudioDeviceID, callback: AudioPostm
return c.SDL_SetAudioPostmixCallback(devid, callback, userdata);
}
pub inline fn loadWAV(path: [*c]const u8, spec: ?*AudioSpec, audio_buf: Uint8 **, audio_len: *u32,) bool {
pub inline fn loadWAV(path: [*c]const u8, spec: ?*AudioSpec, audio_buf: Uint8 **, audio_len: *u32) bool {
return c.SDL_LoadWAV(path, spec, audio_buf, @ptrCast(audio_len));
}
pub inline fn mixAudio(dst: [*c]u8, src: [*c]const u8, format: AudioFormat, len: u32, volume: f32,) bool {
pub inline fn mixAudio(dst: [*c]u8, src: [*c]const u8, format: AudioFormat, len: u32, volume: f32) bool {
return c.SDL_MixAudio(dst, src, @bitCast(format), len, volume);
}
pub inline fn convertAudioSamples(src_spec: *const AudioSpec, src_data: [*c]const u8, src_len: c_int, dst_spec: *const AudioSpec, dst_data: Uint8 **, dst_len: *c_int,) bool {
pub inline fn convertAudioSamples(src_spec: *const AudioSpec, src_data: [*c]const u8, src_len: c_int, dst_spec: *const AudioSpec, dst_data: Uint8 **, dst_len: *c_int) bool {
return c.SDL_ConvertAudioSamples(@ptrCast(src_spec), src_data, src_len, @ptrCast(dst_spec), dst_data, @ptrCast(dst_len));
}

View File

@ -3,13 +3,6 @@ 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 {
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)));
}

View File

@ -29,13 +29,7 @@ pub const ClipboardDataCallback = *const fn (userdata: ?*anyopaque, mime_type: [
pub const ClipboardCleanupCallback = *const fn (userdata: ?*anyopaque) callconv(.C) void;
pub inline fn setClipboardData(
callback: ClipboardDataCallback,
cleanup: ClipboardCleanupCallback,
userdata: ?*anyopaque,
mime_types: [*c][*c]const u8,
num_mime_types: usize,
) bool {
pub inline fn setClipboardData(callback: ClipboardDataCallback, cleanup: ClipboardCleanupCallback, userdata: ?*anyopaque, mime_types: [*c][*c]const u8, num_mime_types: usize) bool {
return c.SDL_SetClipboardData(callback, cleanup, userdata, mime_types, num_mime_types);
}

View File

@ -12,36 +12,15 @@ pub const DialogFileFilter = extern struct {
pub const DialogFileCallback = *const fn (userdata: ?*anyopaque, filelist: [*c]const [*c]const u8, filter: c_int) callconv(.C) void;
pub inline fn showOpenFileDialog(
callback: DialogFileCallback,
userdata: ?*anyopaque,
window: ?*Window,
filters: *const DialogFileFilter,
nfilters: c_int,
default_location: [*c]const u8,
allow_many: bool,
) void {
pub inline fn showOpenFileDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, filters: *const DialogFileFilter, nfilters: c_int, default_location: [*c]const u8, allow_many: bool) void {
return c.SDL_ShowOpenFileDialog(callback, userdata, window, @ptrCast(filters), nfilters, default_location, allow_many);
}
pub inline fn showSaveFileDialog(
callback: DialogFileCallback,
userdata: ?*anyopaque,
window: ?*Window,
filters: *const DialogFileFilter,
nfilters: c_int,
default_location: [*c]const u8,
) void {
pub inline fn showSaveFileDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, filters: *const DialogFileFilter, nfilters: c_int, default_location: [*c]const u8) void {
return c.SDL_ShowSaveFileDialog(callback, userdata, window, @ptrCast(filters), nfilters, default_location);
}
pub inline fn showOpenFolderDialog(
callback: DialogFileCallback,
userdata: ?*anyopaque,
window: ?*Window,
default_location: [*c]const u8,
allow_many: bool,
) void {
pub inline fn showOpenFolderDialog(callback: DialogFileCallback, userdata: ?*anyopaque, window: ?*Window, default_location: [*c]const u8, allow_many: bool) void {
return c.SDL_ShowOpenFolderDialog(callback, userdata, window, default_location, allow_many);
}
@ -51,11 +30,6 @@ pub const FileDialogType = enum(c_int) {
filedialogOpenfolder,
};
pub inline fn showFileDialogWithProperties(
type: FileDialogType,
callback: DialogFileCallback,
userdata: ?*anyopaque,
props: PropertiesID,
) void {
pub inline fn showFileDialogWithProperties(type: FileDialogType, callback: DialogFileCallback, userdata: ?*anyopaque, props: PropertiesID) void {
return c.SDL_ShowFileDialogWithProperties(@intFromEnum(type), callback, userdata, props);
}

View File

@ -677,13 +677,7 @@ pub inline fn pumpEvents() void {
return c.SDL_PumpEvents();
}
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);
}

View File

@ -55,12 +55,7 @@ pub inline fn getPathInfo(path: [*c]const u8, info: ?*PathInfo) bool {
return c.SDL_GetPathInfo(path, info);
}
pub inline fn globDirectory(
path: [*c]const u8,
pattern: [*c]const u8,
flags: GlobFlags,
count: *c_int,
) [*c][*c]u8 {
pub inline fn globDirectory(path: [*c]const u8, pattern: [*c]const u8, flags: GlobFlags, count: *c_int) [*c][*c]u8 {
return c.SDL_GlobDirectory(path, pattern, @bitCast(flags), @ptrCast(count));
}

View File

@ -133,15 +133,7 @@ pub const Gamepad = opaque {
return c.SDL_GetNumGamepadTouchpadFingers(gamepad, touchpad);
}
pub inline fn getGamepadTouchpadFinger(
gamepad: *Gamepad,
touchpad: c_int,
finger: c_int,
down: *bool,
x: *f32,
y: *f32,
pressure: *f32,
) bool {
pub inline fn getGamepadTouchpadFinger(gamepad: *Gamepad, touchpad: c_int, finger: c_int, down: *bool, x: *f32, y: *f32, pressure: *f32) bool {
return c.SDL_GetGamepadTouchpadFinger(gamepad, touchpad, finger, @ptrCast(down), @ptrCast(x), @ptrCast(y), @ptrCast(pressure));
}
@ -161,39 +153,19 @@ pub const Gamepad = opaque {
return c.SDL_GetGamepadSensorDataRate(gamepad, @intFromEnum(type));
}
pub inline fn getGamepadSensorData(
gamepad: *Gamepad,
type: SensorType,
data: *f32,
num_values: c_int,
) bool {
pub inline fn getGamepadSensorData(gamepad: *Gamepad, type: SensorType, data: *f32, num_values: c_int) bool {
return c.SDL_GetGamepadSensorData(gamepad, @intFromEnum(type), @ptrCast(data), num_values);
}
pub inline fn rumbleGamepad(
gamepad: *Gamepad,
low_frequency_rumble: u16,
high_frequency_rumble: u16,
duration_ms: u32,
) bool {
pub inline fn rumbleGamepad(gamepad: *Gamepad, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32) bool {
return c.SDL_RumbleGamepad(gamepad, low_frequency_rumble, high_frequency_rumble, duration_ms);
}
pub inline fn rumbleGamepadTriggers(
gamepad: *Gamepad,
left_rumble: u16,
right_rumble: u16,
duration_ms: u32,
) bool {
pub inline fn rumbleGamepadTriggers(gamepad: *Gamepad, left_rumble: u16, right_rumble: u16, duration_ms: u32) bool {
return c.SDL_RumbleGamepadTriggers(gamepad, left_rumble, right_rumble, duration_ms);
}
pub inline fn setGamepadLED(
gamepad: *Gamepad,
red: u8,
green: u8,
blue: u8,
) bool {
pub inline fn setGamepadLED(gamepad: *Gamepad, red: u8, green: u8, blue: u8) bool {
return c.SDL_SetGamepadLED(gamepad, red, green, blue);
}

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

@ -124,12 +124,7 @@ pub const GPUDevice = opaque {
return c.SDL_ReleaseWindowFromGPUDevice(gpudevice, window);
}
pub inline fn setGPUSwapchainParameters(
gpudevice: *GPUDevice,
window: ?*Window,
swapchain_composition: GPUSwapchainComposition,
present_mode: GPUPresentMode,
) bool {
pub inline fn setGPUSwapchainParameters(gpudevice: *GPUDevice, window: ?*Window, swapchain_composition: GPUSwapchainComposition, present_mode: GPUPresentMode) bool {
return c.SDL_SetGPUSwapchainParameters(gpudevice, window, swapchain_composition, @intFromEnum(present_mode));
}
@ -149,12 +144,7 @@ pub const GPUDevice = opaque {
return c.SDL_WaitForGPUIdle(gpudevice);
}
pub inline fn waitForGPUFences(
gpudevice: *GPUDevice,
wait_all: bool,
fences: [*c]*const GPUFence,
num_fences: u32,
) bool {
pub inline fn waitForGPUFences(gpudevice: *GPUDevice, wait_all: bool, fences: [*c]*const GPUFence, num_fences: u32) bool {
return c.SDL_WaitForGPUFences(gpudevice, wait_all, fences, num_fences);
}
@ -166,12 +156,7 @@ pub const GPUDevice = opaque {
return c.SDL_ReleaseGPUFence(gpudevice, fence);
}
pub inline fn gpuTextureSupportsFormat(
gpudevice: *GPUDevice,
format: GPUTextureFormat,
type: GPUTextureType,
usage: GPUTextureUsageFlags,
) bool {
pub inline fn gpuTextureSupportsFormat(gpudevice: *GPUDevice, format: GPUTextureFormat, type: GPUTextureType, usage: GPUTextureUsageFlags) bool {
return c.SDL_GPUTextureSupportsFormat(gpudevice, @bitCast(format), @intFromEnum(type), @bitCast(usage));
}
@ -215,49 +200,23 @@ pub const GPUCommandBuffer = opaque {
return c.SDL_PopGPUDebugGroup(gpucommandbuffer);
}
pub inline fn pushGPUVertexUniformData(
gpucommandbuffer: *GPUCommandBuffer,
slot_index: u32,
data: ?*const anyopaque,
length: u32,
) void {
pub inline fn pushGPUVertexUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
return c.SDL_PushGPUVertexUniformData(gpucommandbuffer, slot_index, data, length);
}
pub inline fn pushGPUFragmentUniformData(
gpucommandbuffer: *GPUCommandBuffer,
slot_index: u32,
data: ?*const anyopaque,
length: u32,
) void {
pub inline fn pushGPUFragmentUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
return c.SDL_PushGPUFragmentUniformData(gpucommandbuffer, slot_index, data, length);
}
pub inline fn pushGPUComputeUniformData(
gpucommandbuffer: *GPUCommandBuffer,
slot_index: u32,
data: ?*const anyopaque,
length: u32,
) void {
pub inline fn pushGPUComputeUniformData(gpucommandbuffer: *GPUCommandBuffer, slot_index: u32, data: ?*const anyopaque, length: u32) void {
return c.SDL_PushGPUComputeUniformData(gpucommandbuffer, slot_index, data, length);
}
pub inline fn beginGPURenderPass(
gpucommandbuffer: *GPUCommandBuffer,
color_target_infos: *const GPUColorTargetInfo,
num_color_targets: u32,
depth_stencil_target_info: *const GPUDepthStencilTargetInfo,
) ?*GPURenderPass {
pub inline fn beginGPURenderPass(gpucommandbuffer: *GPUCommandBuffer, color_target_infos: *const GPUColorTargetInfo, num_color_targets: u32, depth_stencil_target_info: *const GPUDepthStencilTargetInfo) ?*GPURenderPass {
return c.SDL_BeginGPURenderPass(gpucommandbuffer, @ptrCast(color_target_infos), num_color_targets, @ptrCast(depth_stencil_target_info));
}
pub inline fn beginGPUComputePass(
gpucommandbuffer: *GPUCommandBuffer,
storage_texture_bindings: *const GPUStorageTextureReadWriteBinding,
num_storage_texture_bindings: u32,
storage_buffer_bindings: *const GPUStorageBufferReadWriteBinding,
num_storage_buffer_bindings: u32,
) ?*GPUComputePass {
pub inline fn beginGPUComputePass(gpucommandbuffer: *GPUCommandBuffer, storage_texture_bindings: *const GPUStorageTextureReadWriteBinding, num_storage_texture_bindings: u32, storage_buffer_bindings: *const GPUStorageBufferReadWriteBinding, num_storage_buffer_bindings: u32) ?*GPUComputePass {
return c.SDL_BeginGPUComputePass(gpucommandbuffer, @ptrCast(storage_texture_bindings), num_storage_texture_bindings, @ptrCast(storage_buffer_bindings), num_storage_buffer_bindings);
}
@ -273,23 +232,11 @@ pub const GPUCommandBuffer = opaque {
return c.SDL_BlitGPUTexture(gpucommandbuffer, @ptrCast(info));
}
pub inline fn acquireGPUSwapchainTexture(
gpucommandbuffer: *GPUCommandBuffer,
window: ?*Window,
swapchain_texture: ?*?*GPUTexture,
swapchain_texture_width: *u32,
swapchain_texture_height: *u32,
) bool {
pub inline fn acquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: ?*?*GPUTexture, swapchain_texture_width: *u32, swapchain_texture_height: *u32) bool {
return c.SDL_AcquireGPUSwapchainTexture(gpucommandbuffer, window, swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height));
}
pub inline fn waitAndAcquireGPUSwapchainTexture(
gpucommandbuffer: *GPUCommandBuffer,
window: ?*Window,
swapchain_texture: ?*?*GPUTexture,
swapchain_texture_width: *u32,
swapchain_texture_height: *u32,
) bool {
pub inline fn waitAndAcquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: ?*?*GPUTexture, swapchain_texture_width: *u32, swapchain_texture_height: *u32) bool {
return c.SDL_WaitAndAcquireGPUSwapchainTexture(gpucommandbuffer, window, swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height));
}
@ -327,12 +274,7 @@ pub const GPURenderPass = opaque {
return c.SDL_SetGPUStencilReference(gpurenderpass, reference);
}
pub inline fn bindGPUVertexBuffers(
gpurenderpass: *GPURenderPass,
first_slot: u32,
bindings: *const GPUBufferBinding,
num_bindings: u32,
) void {
pub inline fn bindGPUVertexBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, bindings: *const GPUBufferBinding, num_bindings: u32) void {
return c.SDL_BindGPUVertexBuffers(gpurenderpass, first_slot, @ptrCast(bindings), num_bindings);
}
@ -340,96 +282,43 @@ pub const GPURenderPass = opaque {
return c.SDL_BindGPUIndexBuffer(gpurenderpass, @ptrCast(binding), index_element_size);
}
pub inline fn bindGPUVertexSamplers(
gpurenderpass: *GPURenderPass,
first_slot: u32,
texture_sampler_bindings: *const GPUTextureSamplerBinding,
num_bindings: u32,
) void {
pub inline fn bindGPUVertexSamplers(gpurenderpass: *GPURenderPass, first_slot: u32, texture_sampler_bindings: *const GPUTextureSamplerBinding, num_bindings: u32) void {
return c.SDL_BindGPUVertexSamplers(gpurenderpass, first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
}
pub inline fn bindGPUVertexStorageTextures(
gpurenderpass: *GPURenderPass,
first_slot: u32,
storage_textures: [*c]*const GPUTexture,
num_bindings: u32,
) void {
pub inline fn bindGPUVertexStorageTextures(gpurenderpass: *GPURenderPass, first_slot: u32, storage_textures: [*c]*const GPUTexture, num_bindings: u32) void {
return c.SDL_BindGPUVertexStorageTextures(gpurenderpass, first_slot, storage_textures, num_bindings);
}
pub inline fn bindGPUVertexStorageBuffers(
gpurenderpass: *GPURenderPass,
first_slot: u32,
storage_buffers: [*c]*const GPUBuffer,
num_bindings: u32,
) void {
pub inline fn bindGPUVertexStorageBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, storage_buffers: [*c]*const GPUBuffer, num_bindings: u32) void {
return c.SDL_BindGPUVertexStorageBuffers(gpurenderpass, first_slot, storage_buffers, num_bindings);
}
pub inline fn bindGPUFragmentSamplers(
gpurenderpass: *GPURenderPass,
first_slot: u32,
texture_sampler_bindings: *const GPUTextureSamplerBinding,
num_bindings: u32,
) void {
pub inline fn bindGPUFragmentSamplers(gpurenderpass: *GPURenderPass, first_slot: u32, texture_sampler_bindings: *const GPUTextureSamplerBinding, num_bindings: u32) void {
return c.SDL_BindGPUFragmentSamplers(gpurenderpass, first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
}
pub inline fn bindGPUFragmentStorageTextures(
gpurenderpass: *GPURenderPass,
first_slot: u32,
storage_textures: [*c]*const GPUTexture,
num_bindings: u32,
) void {
pub inline fn bindGPUFragmentStorageTextures(gpurenderpass: *GPURenderPass, first_slot: u32, storage_textures: [*c]*const GPUTexture, num_bindings: u32) void {
return c.SDL_BindGPUFragmentStorageTextures(gpurenderpass, first_slot, storage_textures, num_bindings);
}
pub inline fn bindGPUFragmentStorageBuffers(
gpurenderpass: *GPURenderPass,
first_slot: u32,
storage_buffers: [*c]*const GPUBuffer,
num_bindings: u32,
) void {
pub inline fn bindGPUFragmentStorageBuffers(gpurenderpass: *GPURenderPass, first_slot: u32, storage_buffers: [*c]*const GPUBuffer, num_bindings: u32) void {
return c.SDL_BindGPUFragmentStorageBuffers(gpurenderpass, first_slot, storage_buffers, num_bindings);
}
pub inline fn drawGPUIndexedPrimitives(
gpurenderpass: *GPURenderPass,
num_indices: u32,
num_instances: u32,
first_index: u32,
vertex_offset: i32,
first_instance: u32,
) void {
pub inline fn drawGPUIndexedPrimitives(gpurenderpass: *GPURenderPass, num_indices: u32, num_instances: u32, first_index: u32, vertex_offset: i32, first_instance: u32) void {
return c.SDL_DrawGPUIndexedPrimitives(gpurenderpass, num_indices, num_instances, first_index, vertex_offset, first_instance);
}
pub inline fn drawGPUPrimitives(
gpurenderpass: *GPURenderPass,
num_vertices: u32,
num_instances: u32,
first_vertex: u32,
first_instance: u32,
) void {
pub inline fn drawGPUPrimitives(gpurenderpass: *GPURenderPass, num_vertices: u32, num_instances: u32, first_vertex: u32, first_instance: u32) void {
return c.SDL_DrawGPUPrimitives(gpurenderpass, num_vertices, num_instances, first_vertex, first_instance);
}
pub inline fn drawGPUPrimitivesIndirect(
gpurenderpass: *GPURenderPass,
buffer: ?*GPUBuffer,
offset: u32,
draw_count: u32,
) void {
pub inline fn drawGPUPrimitivesIndirect(gpurenderpass: *GPURenderPass, buffer: ?*GPUBuffer, offset: u32, draw_count: u32) void {
return c.SDL_DrawGPUPrimitivesIndirect(gpurenderpass, buffer, offset, draw_count);
}
pub inline fn drawGPUIndexedPrimitivesIndirect(
gpurenderpass: *GPURenderPass,
buffer: ?*GPUBuffer,
offset: u32,
draw_count: u32,
) void {
pub inline fn drawGPUIndexedPrimitivesIndirect(gpurenderpass: *GPURenderPass, buffer: ?*GPUBuffer, offset: u32, draw_count: u32) void {
return c.SDL_DrawGPUIndexedPrimitivesIndirect(gpurenderpass, buffer, offset, draw_count);
}
@ -443,39 +332,19 @@ pub const GPUComputePass = opaque {
return c.SDL_BindGPUComputePipeline(gpucomputepass, compute_pipeline);
}
pub inline fn bindGPUComputeSamplers(
gpucomputepass: *GPUComputePass,
first_slot: u32,
texture_sampler_bindings: *const GPUTextureSamplerBinding,
num_bindings: u32,
) void {
pub inline fn bindGPUComputeSamplers(gpucomputepass: *GPUComputePass, first_slot: u32, texture_sampler_bindings: *const GPUTextureSamplerBinding, num_bindings: u32) void {
return c.SDL_BindGPUComputeSamplers(gpucomputepass, first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
}
pub inline fn bindGPUComputeStorageTextures(
gpucomputepass: *GPUComputePass,
first_slot: u32,
storage_textures: [*c]*const GPUTexture,
num_bindings: u32,
) void {
pub inline fn bindGPUComputeStorageTextures(gpucomputepass: *GPUComputePass, first_slot: u32, storage_textures: [*c]*const GPUTexture, num_bindings: u32) void {
return c.SDL_BindGPUComputeStorageTextures(gpucomputepass, first_slot, storage_textures, num_bindings);
}
pub inline fn bindGPUComputeStorageBuffers(
gpucomputepass: *GPUComputePass,
first_slot: u32,
storage_buffers: [*c]*const GPUBuffer,
num_bindings: u32,
) void {
pub inline fn bindGPUComputeStorageBuffers(gpucomputepass: *GPUComputePass, first_slot: u32, storage_buffers: [*c]*const GPUBuffer, num_bindings: u32) void {
return c.SDL_BindGPUComputeStorageBuffers(gpucomputepass, first_slot, storage_buffers, num_bindings);
}
pub inline fn dispatchGPUCompute(
gpucomputepass: *GPUComputePass,
groupcount_x: u32,
groupcount_y: u32,
groupcount_z: u32,
) void {
pub inline fn dispatchGPUCompute(gpucomputepass: *GPUComputePass, groupcount_x: u32, groupcount_y: u32, groupcount_z: u32) void {
return c.SDL_DispatchGPUCompute(gpucomputepass, groupcount_x, groupcount_y, groupcount_z);
}
@ -489,43 +358,19 @@ pub const GPUComputePass = opaque {
};
pub const GPUCopyPass = opaque {
pub inline fn uploadToGPUTexture(
gpucopypass: *GPUCopyPass,
source: *const GPUTextureTransferInfo,
destination: *const GPUTextureRegion,
cycle: bool,
) void {
pub inline fn uploadToGPUTexture(gpucopypass: *GPUCopyPass, source: *const GPUTextureTransferInfo, destination: *const GPUTextureRegion, cycle: bool) void {
return c.SDL_UploadToGPUTexture(gpucopypass, @ptrCast(source), @ptrCast(destination), cycle);
}
pub inline fn uploadToGPUBuffer(
gpucopypass: *GPUCopyPass,
source: *const GPUTransferBufferLocation,
destination: *const GPUBufferRegion,
cycle: bool,
) void {
pub inline fn uploadToGPUBuffer(gpucopypass: *GPUCopyPass, source: *const GPUTransferBufferLocation, destination: *const GPUBufferRegion, cycle: bool) void {
return c.SDL_UploadToGPUBuffer(gpucopypass, @ptrCast(source), @ptrCast(destination), cycle);
}
pub inline fn copyGPUTextureToTexture(
gpucopypass: *GPUCopyPass,
source: *const GPUTextureLocation,
destination: *const GPUTextureLocation,
w: u32,
h: u32,
d: u32,
cycle: bool,
) void {
pub inline fn copyGPUTextureToTexture(gpucopypass: *GPUCopyPass, source: *const GPUTextureLocation, destination: *const GPUTextureLocation, w: u32, h: u32, d: u32, cycle: bool) void {
return c.SDL_CopyGPUTextureToTexture(gpucopypass, @ptrCast(source), @ptrCast(destination), w, h, d, cycle);
}
pub inline fn copyGPUBufferToBuffer(
gpucopypass: *GPUCopyPass,
source: *const GPUBufferLocation,
destination: *const GPUBufferLocation,
size: u32,
cycle: bool,
) void {
pub inline fn copyGPUBufferToBuffer(gpucopypass: *GPUCopyPass, source: *const GPUBufferLocation, destination: *const GPUBufferLocation, size: u32, cycle: bool) void {
return c.SDL_CopyGPUBufferToBuffer(gpucopypass, @ptrCast(source), @ptrCast(destination), size, cycle);
}
@ -1128,11 +973,6 @@ pub inline fn gpuTextureFormatTexelBlockSize(format: GPUTextureFormat) u32 {
return c.SDL_GPUTextureFormatTexelBlockSize(@bitCast(format));
}
pub inline fn calculateGPUTextureFormatSize(
format: GPUTextureFormat,
width: u32,
height: u32,
depth_or_layer_count: u32,
) u32 {
pub inline fn calculateGPUTextureFormatSize(format: GPUTextureFormat, width: u32, height: u32, depth_or_layer_count: u32) u32 {
return c.SDL_CalculateGPUTextureFormatSize(@bitCast(format), width, height, depth_or_layer_count);
}

View File

@ -9,7 +9,6 @@ pub const Joystick = opaque {
pub inline fn openHapticFromJoystick(joystick: *Joystick) ?*Haptic {
return c.SDL_OpenHapticFromJoystick(joystick);
}
};
pub const Haptic = opaque {
@ -104,7 +103,6 @@ pub const Haptic = opaque {
pub inline fn stopHapticRumble(haptic: *Haptic) bool {
return c.SDL_StopHapticRumble(haptic);
}
};
pub const HapticDirection = extern struct {
@ -188,7 +186,7 @@ pub const HapticCustom = extern struct {
channels: u8, // Axes to use, minimum of one.
period: u16, // Sample periods.
samples: u16, // Amount of samples.
data: Uint16 *, // Should contain channels*samples items.
data: *u16, // Should contain channels*samples items.
attack_length: u16, // Duration of the attack.
attack_level: u16, // Level at the start of the attack.
fade_length: u16, // Duration of the fade.
@ -230,4 +228,3 @@ pub inline fn isMouseHaptic() bool {
pub inline fn openHapticFromMouse() ?*Haptic {
return c.SDL_OpenHapticFromMouse();
}

View File

@ -6,7 +6,7 @@ pub const hid_device = opaque {
return c.SDL_hid_write(hid_device, data, length);
}
pub inline fn hid_read_timeout(hid_device: *hid_device, data: unsigned char *, length: usize, milliseconds: c_int,) c_int {
pub inline fn hid_read_timeout(hid_device: *hid_device, data: unsigned char *, length: usize, milliseconds: c_int) c_int {
return c.SDL_hid_read_timeout(hid_device, data, length, milliseconds);
}
@ -46,7 +46,7 @@ pub const hid_device = opaque {
return c.SDL_hid_get_serial_number_string(hid_device, string, maxlen);
}
pub inline fn hid_get_indexed_string(hid_device: *hid_device, string_index: c_int, string: wchar_t *, maxlen: usize,) c_int {
pub inline fn hid_get_indexed_string(hid_device: *hid_device, string_index: c_int, string: wchar_t *, maxlen: usize) c_int {
return c.SDL_hid_get_indexed_string(hid_device, string_index, string, maxlen);
}

View File

@ -62,7 +62,7 @@ pub const IOStream = opaque {
return c.SDL_LoadFile_IO(iostream, @ptrCast(datasize), closeio);
}
pub inline fn saveFile_IO(iostream: *IOStream, data: ?*const anyopaque, datasize: usize, closeio: bool,) bool {
pub inline fn saveFile_IO(iostream: *IOStream, data: ?*const anyopaque, datasize: usize, closeio: bool) bool {
return c.SDL_SaveFile_IO(iostream, data, datasize, closeio);
}
@ -74,20 +74,20 @@ pub const IOStream = opaque {
return c.SDL_ReadS8(iostream, value);
}
pub inline fn readU16LE(iostream: *IOStream, value: Uint16 *) bool {
return c.SDL_ReadU16LE(iostream, value);
pub inline fn readU16LE(iostream: *IOStream, value: *u16) bool {
return c.SDL_ReadU16LE(iostream, @ptrCast(value));
}
pub inline fn readS16LE(iostream: *IOStream, value: Sint16 *) bool {
return c.SDL_ReadS16LE(iostream, value);
pub inline fn readS16LE(iostream: *IOStream, value: *i16) bool {
return c.SDL_ReadS16LE(iostream, @ptrCast(value));
}
pub inline fn readU16BE(iostream: *IOStream, value: Uint16 *) bool {
return c.SDL_ReadU16BE(iostream, value);
pub inline fn readU16BE(iostream: *IOStream, value: *u16) bool {
return c.SDL_ReadU16BE(iostream, @ptrCast(value));
}
pub inline fn readS16BE(iostream: *IOStream, value: Sint16 *) bool {
return c.SDL_ReadS16BE(iostream, value);
pub inline fn readS16BE(iostream: *IOStream, value: *i16) bool {
return c.SDL_ReadS16BE(iostream, @ptrCast(value));
}
pub inline fn readU32LE(iostream: *IOStream, value: *u32) bool {

View File

@ -12,7 +12,7 @@ pub const Joystick = opaque {
return c.SDL_SetJoystickVirtualAxis(joystick, axis, value);
}
pub inline fn setJoystickVirtualBall(joystick: *Joystick, ball: c_int, xrel: i16, yrel: i16,) bool {
pub inline fn setJoystickVirtualBall(joystick: *Joystick, ball: c_int, xrel: i16, yrel: i16) bool {
return c.SDL_SetJoystickVirtualBall(joystick, ball, xrel, yrel);
}
@ -24,12 +24,12 @@ pub const Joystick = opaque {
return c.SDL_SetJoystickVirtualHat(joystick, hat, value);
}
pub inline fn setJoystickVirtualTouchpad(joystick: *Joystick, touchpad: c_int, finger: c_int, down: bool, x: f32, y: f32, pressure: f32,) bool {
pub inline fn setJoystickVirtualTouchpad(joystick: *Joystick, touchpad: c_int, finger: c_int, down: bool, x: f32, y: f32, pressure: f32) bool {
return c.SDL_SetJoystickVirtualTouchpad(joystick, touchpad, finger, down, x, y, pressure);
}
pub inline fn sendJoystickVirtualSensorData(joystick: *Joystick, type: SensorType, sensor_timestamp: u64, data: const float *, num_values: c_int,) bool {
return c.SDL_SendJoystickVirtualSensorData(joystick, @intFromEnum(type), sensor_timestamp, data, num_values);
pub inline fn sendJoystickVirtualSensorData(joystick: *Joystick, type: SensorType, sensor_timestamp: u64, data: *const f32, num_values: c_int) bool {
return c.SDL_SendJoystickVirtualSensorData(joystick, @intFromEnum(type), sensor_timestamp, @ptrCast(data), num_values);
}
pub inline fn getJoystickProperties(joystick: *Joystick) PropertiesID {
@ -108,11 +108,11 @@ pub const Joystick = opaque {
return c.SDL_GetJoystickAxis(joystick, axis);
}
pub inline fn getJoystickAxisInitialState(joystick: *Joystick, axis: c_int, state: Sint16 *) bool {
return c.SDL_GetJoystickAxisInitialState(joystick, axis, state);
pub inline fn getJoystickAxisInitialState(joystick: *Joystick, axis: c_int, state: *i16) bool {
return c.SDL_GetJoystickAxisInitialState(joystick, axis, @ptrCast(state));
}
pub inline fn getJoystickBall(joystick: *Joystick, ball: c_int, dx: *c_int, dy: *c_int,) bool {
pub inline fn getJoystickBall(joystick: *Joystick, ball: c_int, dx: *c_int, dy: *c_int) bool {
return c.SDL_GetJoystickBall(joystick, ball, @ptrCast(dx), @ptrCast(dy));
}
@ -124,15 +124,15 @@ pub const Joystick = opaque {
return c.SDL_GetJoystickButton(joystick, button);
}
pub inline fn rumbleJoystick(joystick: *Joystick, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32,) bool {
pub inline fn rumbleJoystick(joystick: *Joystick, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32) bool {
return c.SDL_RumbleJoystick(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms);
}
pub inline fn rumbleJoystickTriggers(joystick: *Joystick, left_rumble: u16, right_rumble: u16, duration_ms: u32,) bool {
pub inline fn rumbleJoystickTriggers(joystick: *Joystick, left_rumble: u16, right_rumble: u16, duration_ms: u32) bool {
return c.SDL_RumbleJoystickTriggers(joystick, left_rumble, right_rumble, duration_ms);
}
pub inline fn setJoystickLED(joystick: *Joystick, red: u8, green: u8, blue: u8,) bool {
pub inline fn setJoystickLED(joystick: *Joystick, red: u8, green: u8, blue: u8) bool {
return c.SDL_SetJoystickLED(joystick, red, green, blue);
}
@ -151,7 +151,6 @@ pub const Joystick = opaque {
pub inline fn getJoystickPowerInfo(joystick: *Joystick, percent: *c_int) PowerState {
return c.SDL_GetJoystickPowerInfo(joystick, @ptrCast(percent));
}
};
pub const JoystickID = u32;
@ -177,12 +176,12 @@ pub const JoystickConnectionState = enum(c_int) {
joystickConnectionWireless,
};
pub inline fn lockJoysticks(SDL_ACQUIRE(SDL_joystick_lock: void)) void {
return c.SDL_LockJoysticks(SDL_ACQUIRE(SDL_joystick_lock);
pub inline fn lockJoysticks() void {
return c.SDL_LockJoysticks();
}
pub inline fn unlockJoysticks(SDL_RELEASE(SDL_joystick_lock: void)) void {
return c.SDL_UnlockJoysticks(SDL_RELEASE(SDL_joystick_lock);
pub inline fn unlockJoysticks() void {
return c.SDL_UnlockJoysticks();
}
pub inline fn hasJoystick() bool {
@ -286,8 +285,8 @@ pub inline fn isJoystickVirtual(instance_id: JoystickID) bool {
return c.SDL_IsJoystickVirtual(instance_id);
}
pub inline fn getJoystickGUIDInfo(guid: GUID, vendor: Uint16 *, product: Uint16 *, version: Uint16 *, crc16: Uint16 *,) void {
return c.SDL_GetJoystickGUIDInfo(guid, vendor, product, version, crc16);
pub inline fn getJoystickGUIDInfo(guid: GUID, vendor: *u16, product: *u16, version: *u16, crc16: *u16) void {
return c.SDL_GetJoystickGUIDInfo(guid, @ptrCast(vendor), @ptrCast(product), @ptrCast(version), @ptrCast(crc16));
}
pub inline fn setJoystickEventsEnabled(enabled: bool) void {
@ -301,4 +300,3 @@ pub inline fn joystickEventsEnabled() bool {
pub inline fn updateJoysticks() void {
return c.SDL_UpdateJoysticks();
}

14
lib/sdl3/v2/log.zig vendored
View File

@ -111,12 +111,7 @@ pub inline fn logCritical(category: c_int, fmt: [*c]const u8, ...) void {
);
}
pub inline fn logMessage(
category: c_int,
priority: LogPriority,
fmt: [*c]const u8,
...,
) void {
pub inline fn logMessage(category: c_int, priority: LogPriority, fmt: [*c]const u8, ...) void {
return c.SDL_LogMessage(
category,
priority,
@ -124,12 +119,7 @@ pub inline fn logMessage(
);
}
pub inline fn logMessageV(
category: c_int,
priority: LogPriority,
fmt: [*c]const u8,
ap: std.builtin.VaList,
) void {
pub inline fn logMessageV(category: c_int, priority: LogPriority, fmt: [*c]const u8, ap: std.builtin.VaList) void {
return c.SDL_LogMessageV(category, priority, fmt, ap);
}

View File

@ -58,11 +58,6 @@ pub inline fn showMessageBox(messageboxdata: *const MessageBoxData, buttonid: *c
return c.SDL_ShowMessageBox(@ptrCast(messageboxdata), @ptrCast(buttonid));
}
pub inline fn showSimpleMessageBox(
flags: MessageBoxFlags,
title: [*c]const u8,
message: [*c]const u8,
window: ?*Window,
) bool {
pub inline fn showSimpleMessageBox(flags: MessageBoxFlags, title: [*c]const u8, message: [*c]const u8, window: ?*Window) bool {
return c.SDL_ShowSimpleMessageBox(@bitCast(flags), title, message, window);
}

View File

@ -81,14 +81,7 @@ 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 {
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);
}

40
lib/sdl3/v2/mutex.zig vendored
View File

@ -7,6 +7,14 @@ pub const AtomicInt = extern struct {
};
pub const Mutex = opaque {
pub inline fn lockMutex(mutex: *Mutex) void {
return c.SDL_LockMutex(mutex);
}
pub inline fn unlockMutex(mutex: *Mutex) void {
return c.SDL_UnlockMutex(mutex);
}
pub inline fn destroyMutex(mutex: *Mutex) void {
return c.SDL_DestroyMutex(mutex);
}
@ -17,19 +25,23 @@ pub inline fn createMutex() ?*Mutex {
return c.SDL_CreateMutex();
}
pub inline fn lockMutex(SDL_ACQUIRE(mutex: Mutex *mutex)) void {
return c.SDL_LockMutex(SDL_ACQUIRE(mutex);
}
pub inline fn tryLockMutex(SDL_TRY_ACQUIRE(0: Mutex *mutex), mutex) bool {
return c.SDL_TryLockMutex(SDL_TRY_ACQUIRE(0, );
}
pub inline fn unlockMutex(SDL_RELEASE(mutex: Mutex *mutex)) void {
return c.SDL_UnlockMutex(SDL_RELEASE(mutex);
}
pub const RWLock = opaque {
pub inline fn lockRWLockForReading(rwlock: *RWLock) void {
return c.SDL_LockRWLockForReading(rwlock);
}
pub inline fn lockRWLockForWriting(rwlock: *RWLock) void {
return c.SDL_LockRWLockForWriting(rwlock);
}
pub inline fn unlockRWLock(rwlock: *RWLock) void {
return c.SDL_UnlockRWLock(rwlock);
}
pub inline fn destroyRWLock(rwlock: *RWLock) void {
return c.SDL_DestroyRWLock(rwlock);
}
@ -40,14 +52,6 @@ pub inline fn createRWLock() ?*RWLock {
return c.SDL_CreateRWLock();
}
pub inline fn lockRWLockForReading(SDL_ACQUIRE_SHARED(rwlock: RWLock *rwlock)) void {
return c.SDL_LockRWLockForReading(SDL_ACQUIRE_SHARED(rwlock);
}
pub inline fn lockRWLockForWriting(SDL_ACQUIRE(rwlock: RWLock *rwlock)) void {
return c.SDL_LockRWLockForWriting(SDL_ACQUIRE(rwlock);
}
pub inline fn tryLockRWLockForReading(SDL_TRY_ACQUIRE_SHARED(0: RWLock *rwlock), rwlock) bool {
return c.SDL_TryLockRWLockForReading(SDL_TRY_ACQUIRE_SHARED(0, );
}
@ -56,10 +60,6 @@ pub inline fn tryLockRWLockForWriting(SDL_TRY_ACQUIRE(0: RWLock *rwlock), rwlock
return c.SDL_TryLockRWLockForWriting(SDL_TRY_ACQUIRE(0, );
}
pub inline fn unlockRWLock(SDL_RELEASE_GENERIC(rwlock: RWLock *rwlock)) void {
return c.SDL_UnlockRWLock(SDL_RELEASE_GENERIC(rwlock);
}
pub const Semaphore = opaque {
pub inline fn destroySemaphore(semaphore: *Semaphore) void {
return c.SDL_DestroySemaphore(semaphore);

View File

@ -205,24 +205,11 @@ 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 {
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 {
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));
}
@ -234,12 +221,7 @@ 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 {
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);
}
@ -247,46 +229,18 @@ 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 {
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 {
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 {
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 {
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);
}

View File

@ -34,13 +34,7 @@ pub inline fn unlockProperties(props: PropertiesID) void {
pub const CleanupPropertyCallback = *const fn (userdata: ?*anyopaque, value: ?*anyopaque) callconv(.C) void;
pub inline fn setPointerPropertyWithCleanup(
props: PropertiesID,
name: [*c]const u8,
value: ?*anyopaque,
cleanup: CleanupPropertyCallback,
userdata: ?*anyopaque,
) bool {
pub inline fn setPointerPropertyWithCleanup(props: PropertiesID, name: [*c]const u8, value: ?*anyopaque, cleanup: CleanupPropertyCallback, userdata: ?*anyopaque) bool {
return c.SDL_SetPointerPropertyWithCleanup(props, name, value, cleanup, userdata);
}

30
lib/sdl3/v2/rect.zig vendored
View File

@ -37,22 +37,11 @@ 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 {
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 {
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));
}
@ -68,21 +57,10 @@ pub inline fn getRectUnionFloat(A: *const FRect, B: *const FRect, result: ?*FRec
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 {
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 {
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));
}

View File

@ -218,7 +218,7 @@ pub const Renderer = opaque {
return c.SDL_GetCurrentRenderOutputSize(renderer, @ptrCast(w), @ptrCast(h));
}
pub inline fn createTexture(renderer: *Renderer, format: PixelFormat, access: TextureAccess, w: c_int, h: c_int,) ?*Texture {
pub inline fn createTexture(renderer: *Renderer, format: PixelFormat, access: TextureAccess, w: c_int, h: c_int) ?*Texture {
return c.SDL_CreateTexture(renderer, @bitCast(format), access, w, h);
}
@ -238,11 +238,11 @@ pub const Renderer = opaque {
return c.SDL_GetRenderTarget(renderer);
}
pub inline fn setRenderLogicalPresentation(renderer: *Renderer, w: c_int, h: c_int, mode: RendererLogicalPresentation,) bool {
pub inline fn setRenderLogicalPresentation(renderer: *Renderer, w: c_int, h: c_int, mode: RendererLogicalPresentation) bool {
return c.SDL_SetRenderLogicalPresentation(renderer, w, h, mode);
}
pub inline fn getRenderLogicalPresentation(renderer: *Renderer, w: *c_int, h: *c_int, mode: ?*RendererLogicalPresentation,) bool {
pub inline fn getRenderLogicalPresentation(renderer: *Renderer, w: *c_int, h: *c_int, mode: ?*RendererLogicalPresentation) bool {
return c.SDL_GetRenderLogicalPresentation(renderer, @ptrCast(w), @ptrCast(h), mode);
}
@ -250,11 +250,11 @@ pub const Renderer = opaque {
return c.SDL_GetRenderLogicalPresentationRect(renderer, rect);
}
pub inline fn renderCoordinatesFromWindow(renderer: *Renderer, window_x: f32, window_y: f32, x: *f32, y: *f32,) bool {
pub inline fn renderCoordinatesFromWindow(renderer: *Renderer, window_x: f32, window_y: f32, x: *f32, y: *f32) bool {
return c.SDL_RenderCoordinatesFromWindow(renderer, window_x, window_y, @ptrCast(x), @ptrCast(y));
}
pub inline fn renderCoordinatesToWindow(renderer: *Renderer, x: f32, y: f32, window_x: *f32, window_y: *f32,) bool {
pub inline fn renderCoordinatesToWindow(renderer: *Renderer, x: f32, y: f32, window_x: *f32, window_y: *f32) bool {
return c.SDL_RenderCoordinatesToWindow(renderer, x, y, @ptrCast(window_x), @ptrCast(window_y));
}
@ -298,19 +298,19 @@ pub const Renderer = opaque {
return c.SDL_GetRenderScale(renderer, @ptrCast(scaleX), @ptrCast(scaleY));
}
pub inline fn setRenderDrawColor(renderer: *Renderer, r: u8, g: u8, b: u8, a: u8,) bool {
pub inline fn setRenderDrawColor(renderer: *Renderer, r: u8, g: u8, b: u8, a: u8) bool {
return c.SDL_SetRenderDrawColor(renderer, r, g, b, a);
}
pub inline fn setRenderDrawColorFloat(renderer: *Renderer, r: f32, g: f32, b: f32, a: f32,) bool {
pub inline fn setRenderDrawColorFloat(renderer: *Renderer, r: f32, g: f32, b: f32, a: f32) bool {
return c.SDL_SetRenderDrawColorFloat(renderer, r, g, b, a);
}
pub inline fn getRenderDrawColor(renderer: *Renderer, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8,) bool {
pub inline fn getRenderDrawColor(renderer: *Renderer, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) bool {
return c.SDL_GetRenderDrawColor(renderer, r, g, b, a);
}
pub inline fn getRenderDrawColorFloat(renderer: *Renderer, r: *f32, g: *f32, b: *f32, a: *f32,) bool {
pub inline fn getRenderDrawColorFloat(renderer: *Renderer, r: *f32, g: *f32, b: *f32, a: *f32) bool {
return c.SDL_GetRenderDrawColorFloat(renderer, @ptrCast(r), @ptrCast(g), @ptrCast(b), @ptrCast(a));
}
@ -342,7 +342,7 @@ pub const Renderer = opaque {
return c.SDL_RenderPoints(renderer, @ptrCast(points), count);
}
pub inline fn renderLine(renderer: *Renderer, x1: f32, y1: f32, x2: f32, y2: f32,) bool {
pub inline fn renderLine(renderer: *Renderer, x1: f32, y1: f32, x2: f32, y2: f32) bool {
return c.SDL_RenderLine(renderer, x1, y1, x2, y2);
}
@ -366,32 +366,32 @@ pub const Renderer = opaque {
return c.SDL_RenderFillRects(renderer, @ptrCast(rects), count);
}
pub inline fn renderTexture(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, dstrect: *const FRect,) bool {
pub inline fn renderTexture(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, dstrect: *const FRect) bool {
return c.SDL_RenderTexture(renderer, texture, @ptrCast(srcrect), @ptrCast(dstrect));
}
pub inline fn renderTextureRotated(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, dstrect: *const FRect, angle: f64, center: *const FPoint, flip: FlipMode,) bool {
pub inline fn renderTextureRotated(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, dstrect: *const FRect, angle: f64, center: *const FPoint, flip: FlipMode) bool {
return c.SDL_RenderTextureRotated(renderer, texture, @ptrCast(srcrect), @ptrCast(dstrect), angle, @ptrCast(center), @intFromEnum(flip));
}
pub inline fn renderTextureAffine(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, origin: *const FPoint, right: *const FPoint, down: *const FPoint,) bool {
pub inline fn renderTextureAffine(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, origin: *const FPoint, right: *const FPoint, down: *const FPoint) bool {
return c.SDL_RenderTextureAffine(renderer, texture, @ptrCast(srcrect), @ptrCast(origin), @ptrCast(right), @ptrCast(down));
}
pub inline fn renderTextureTiled(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, scale: f32, dstrect: *const FRect,) bool {
pub inline fn renderTextureTiled(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, scale: f32, dstrect: *const FRect) bool {
return c.SDL_RenderTextureTiled(renderer, texture, @ptrCast(srcrect), scale, @ptrCast(dstrect));
}
pub inline fn renderTexture9Grid(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: *const FRect,) bool {
pub inline fn renderTexture9Grid(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: *const FRect) bool {
return c.SDL_RenderTexture9Grid(renderer, texture, @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect));
}
pub inline fn renderGeometry(renderer: *Renderer, texture: ?*Texture, vertices: *const Vertex, num_vertices: c_int, indices: const int *, num_indices: c_int,) bool {
pub inline fn renderGeometry(renderer: *Renderer, texture: ?*Texture, vertices: *const Vertex, num_vertices: c_int, indices: const int *, num_indices: c_int) bool {
return c.SDL_RenderGeometry(renderer, texture, @ptrCast(vertices), num_vertices, indices, num_indices);
}
pub inline fn renderGeometryRaw(renderer: *Renderer, texture: ?*Texture, xy: const float *, xy_stride: c_int, color: *const FColor, color_stride: c_int, uv: const float *, uv_stride: c_int, num_vertices: c_int, indices: ?*const anyopaque, num_indices: c_int, size_indices: c_int,) bool {
return c.SDL_RenderGeometryRaw(renderer, texture, xy, xy_stride, @ptrCast(color), color_stride, uv, uv_stride, num_vertices, indices, num_indices, size_indices);
pub inline fn renderGeometryRaw(renderer: *Renderer, texture: ?*Texture, xy: *const f32, xy_stride: c_int, color: *const FColor, color_stride: c_int, uv: *const f32, uv_stride: c_int, num_vertices: c_int, indices: ?*const anyopaque, num_indices: c_int, size_indices: c_int) bool {
return c.SDL_RenderGeometryRaw(renderer, texture, @ptrCast(xy), xy_stride, @ptrCast(color), color_stride, @ptrCast(uv), uv_stride, num_vertices, indices, num_indices, size_indices);
}
pub inline fn renderReadPixels(renderer: *Renderer, rect: *const Rect) ?*Surface {
@ -418,7 +418,7 @@ pub const Renderer = opaque {
return c.SDL_GetRenderMetalCommandEncoder(renderer);
}
pub inline fn addVulkanRenderSemaphores(renderer: *Renderer, wait_stage_mask: u32, wait_semaphore: i64, signal_semaphore: i64,) bool {
pub inline fn addVulkanRenderSemaphores(renderer: *Renderer, wait_stage_mask: u32, wait_semaphore: i64, signal_semaphore: i64) bool {
return c.SDL_AddVulkanRenderSemaphores(renderer, wait_stage_mask, wait_semaphore, signal_semaphore);
}
@ -430,11 +430,11 @@ pub const Renderer = opaque {
return c.SDL_GetRenderVSync(renderer, @ptrCast(vsync));
}
pub inline fn renderDebugText(renderer: *Renderer, x: f32, y: f32, str: [*c]const u8,) bool {
pub inline fn renderDebugText(renderer: *Renderer, x: f32, y: f32, str: [*c]const u8) bool {
return c.SDL_RenderDebugText(renderer, x, y, str);
}
pub inline fn renderDebugTextFormat(renderer: *Renderer, x: f32, y: f32, fmt: [*c]const u8, ...,) bool {
pub inline fn renderDebugTextFormat(renderer: *Renderer, x: f32, y: f32, fmt: [*c]const u8, ...) bool {
return c.SDL_RenderDebugTextFormat(renderer, x, y, fmt, );
}
@ -453,19 +453,19 @@ pub const Texture = opaque {
return c.SDL_GetTextureSize(texture, @ptrCast(w), @ptrCast(h));
}
pub inline fn setTextureColorMod(texture: *Texture, r: u8, g: u8, b: u8,) bool {
pub inline fn setTextureColorMod(texture: *Texture, r: u8, g: u8, b: u8) bool {
return c.SDL_SetTextureColorMod(texture, r, g, b);
}
pub inline fn setTextureColorModFloat(texture: *Texture, r: f32, g: f32, b: f32,) bool {
pub inline fn setTextureColorModFloat(texture: *Texture, r: f32, g: f32, b: f32) bool {
return c.SDL_SetTextureColorModFloat(texture, r, g, b);
}
pub inline fn getTextureColorMod(texture: *Texture, r: [*c]u8, g: [*c]u8, b: [*c]u8,) bool {
pub inline fn getTextureColorMod(texture: *Texture, r: [*c]u8, g: [*c]u8, b: [*c]u8) bool {
return c.SDL_GetTextureColorMod(texture, r, g, b);
}
pub inline fn getTextureColorModFloat(texture: *Texture, r: *f32, g: *f32, b: *f32,) bool {
pub inline fn getTextureColorModFloat(texture: *Texture, r: *f32, g: *f32, b: *f32) bool {
return c.SDL_GetTextureColorModFloat(texture, @ptrCast(r), @ptrCast(g), @ptrCast(b));
}
@ -501,19 +501,19 @@ pub const Texture = opaque {
return c.SDL_GetTextureScaleMode(texture, @intFromEnum(scaleMode));
}
pub inline fn updateTexture(texture: *Texture, rect: *const Rect, pixels: ?*const anyopaque, pitch: c_int,) bool {
pub inline fn updateTexture(texture: *Texture, rect: *const Rect, pixels: ?*const anyopaque, pitch: c_int) bool {
return c.SDL_UpdateTexture(texture, @ptrCast(rect), pixels, pitch);
}
pub inline fn updateYUVTexture(texture: *Texture, rect: *const Rect, Yplane: [*c]const u8, Ypitch: c_int, Uplane: [*c]const u8, Upitch: c_int, Vplane: [*c]const u8, Vpitch: c_int,) bool {
pub inline fn updateYUVTexture(texture: *Texture, rect: *const Rect, Yplane: [*c]const u8, Ypitch: c_int, Uplane: [*c]const u8, Upitch: c_int, Vplane: [*c]const u8, Vpitch: c_int) bool {
return c.SDL_UpdateYUVTexture(texture, @ptrCast(rect), Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
}
pub inline fn updateNVTexture(texture: *Texture, rect: *const Rect, Yplane: [*c]const u8, Ypitch: c_int, UVplane: [*c]const u8, UVpitch: c_int,) bool {
pub inline fn updateNVTexture(texture: *Texture, rect: *const Rect, Yplane: [*c]const u8, Ypitch: c_int, UVplane: [*c]const u8, UVpitch: c_int) bool {
return c.SDL_UpdateNVTexture(texture, @ptrCast(rect), Yplane, Ypitch, UVplane, UVpitch);
}
pub inline fn lockTexture(texture: *Texture, rect: *const Rect, pixels: [*c]?*anyopaque, pitch: *c_int,) bool {
pub inline fn lockTexture(texture: *Texture, rect: *const Rect, pixels: [*c]?*anyopaque, pitch: *c_int) bool {
return c.SDL_LockTexture(texture, @ptrCast(rect), pixels, @ptrCast(pitch));
}
@ -539,7 +539,7 @@ pub inline fn getRenderDriver(index: c_int) [*c]const u8 {
return c.SDL_GetRenderDriver(index);
}
pub inline fn createWindowAndRenderer(title: [*c]const u8, width: c_int, height: c_int, window_flags: WindowFlags, window: ?*?*Window, renderer: ?*?*Renderer,) bool {
pub inline fn createWindowAndRenderer(title: [*c]const u8, width: c_int, height: c_int, window_flags: WindowFlags, window: ?*?*Window, renderer: ?*?*Renderer) bool {
return c.SDL_CreateWindowAndRenderer(title, width, height, @bitCast(window_flags), window, renderer);
}

View File

@ -45,21 +45,11 @@ pub const Storage = opaque {
return c.SDL_GetStorageFileSize(storage, path, @ptrCast(length));
}
pub inline fn readStorageFile(
storage: *Storage,
path: [*c]const u8,
destination: ?*anyopaque,
length: u64,
) bool {
pub inline fn readStorageFile(storage: *Storage, path: [*c]const u8, destination: ?*anyopaque, length: u64) bool {
return c.SDL_ReadStorageFile(storage, path, destination, length);
}
pub inline fn writeStorageFile(
storage: *Storage,
path: [*c]const u8,
source: ?*const anyopaque,
length: u64,
) bool {
pub inline fn writeStorageFile(storage: *Storage, path: [*c]const u8, source: ?*const anyopaque, length: u64) bool {
return c.SDL_WriteStorageFile(storage, path, source, length);
}
@ -67,12 +57,7 @@ pub const Storage = opaque {
return c.SDL_CreateStorageDirectory(storage, path);
}
pub inline fn enumerateStorageDirectory(
storage: *Storage,
path: [*c]const u8,
callback: EnumerateDirectoryCallback,
userdata: ?*anyopaque,
) bool {
pub inline fn enumerateStorageDirectory(storage: *Storage, path: [*c]const u8, callback: EnumerateDirectoryCallback, userdata: ?*anyopaque) bool {
return c.SDL_EnumerateStorageDirectory(storage, path, callback, userdata);
}
@ -96,13 +81,7 @@ pub const Storage = opaque {
return c.SDL_GetStorageSpaceRemaining(storage);
}
pub inline fn globStorageDirectory(
storage: *Storage,
path: [*c]const u8,
pattern: [*c]const u8,
flags: GlobFlags,
count: *c_int,
) [*c][*c]u8 {
pub inline fn globStorageDirectory(storage: *Storage, path: [*c]const u8, pattern: [*c]const u8, flags: GlobFlags, count: *c_int) [*c][*c]u8 {
return c.SDL_GlobStorageDirectory(storage, path, pattern, @bitCast(flags), @ptrCast(count));
}
};

View File

@ -189,21 +189,11 @@ pub const Surface = opaque {
return c.SDL_GetSurfaceColorKey(surface, @ptrCast(key));
}
pub inline fn setSurfaceColorMod(
surface: *Surface,
r: u8,
g: u8,
b: u8,
) bool {
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 {
pub inline fn getSurfaceColorMod(surface: *Surface, r: [*c]u8, g: [*c]u8, b: [*c]u8) bool {
return c.SDL_GetSurfaceColorMod(surface, r, g, b);
}
@ -239,12 +229,7 @@ pub const Surface = opaque {
return c.SDL_DuplicateSurface(surface);
}
pub inline fn scaleSurface(
surface: *Surface,
width: c_int,
height: c_int,
scaleMode: ScaleMode,
) ?*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));
}
@ -252,13 +237,7 @@ pub const Surface = opaque {
return c.SDL_ConvertSurface(surface, @bitCast(format));
}
pub inline fn convertSurfaceAndColorspace(
surface: *Surface,
format: PixelFormat,
palette: ?*Palette,
colorspace: Colorspace,
props: PropertiesID,
) ?*Surface {
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);
}
@ -266,13 +245,7 @@ pub const Surface = opaque {
return c.SDL_PremultiplySurfaceAlpha(surface, linear);
}
pub inline fn clearSurface(
surface: *Surface,
r: f32,
g: f32,
b: f32,
a: f32,
) bool {
pub inline fn clearSurface(surface: *Surface, r: f32, g: f32, b: f32, a: f32) bool {
return c.SDL_ClearSurface(surface, r, g, b, a);
}
@ -280,162 +253,63 @@ pub const Surface = opaque {
return c.SDL_FillSurfaceRect(surface, @ptrCast(rect), color);
}
pub inline fn fillSurfaceRects(
surface: *Surface,
rects: *const Rect,
count: c_int,
color: u32,
) bool {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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);
}
};
@ -444,13 +318,7 @@ pub inline fn createSurface(width: c_int, height: c_int, format: PixelFormat) ?*
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 {
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);
}
@ -458,46 +326,14 @@ 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 {
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 {
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 {
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);
}

View File

@ -47,7 +47,7 @@ pub inline fn createThreadWithProperties(props: PropertiesID) ?*Thread {
return c.SDL_CreateThreadWithProperties(props);
}
pub inline fn createThreadRuntime(fn: ThreadFunction, name: [*c]const u8, data: ?*anyopaque, pfnBeginThread: FunctionPointer, pfnEndThread: FunctionPointer,) ?*Thread {
pub inline fn createThreadRuntime(fn: ThreadFunction, name: [*c]const u8, data: ?*anyopaque, pfnBeginThread: FunctionPointer, pfnEndThread: FunctionPointer) ?*Thread {
return c.SDL_CreateThreadRuntime(fn, name, data, pfnBeginThread, pfnEndThread);
}

View File

@ -36,7 +36,7 @@ pub const TrayMenu = opaque {
return @ptrCast(c.SDL_GetTrayEntries(traymenu, @ptrCast(count)));
}
pub inline fn insertTrayEntryAt(traymenu: *TrayMenu, pos: c_int, label: [*c]const u8, flags: TrayEntryFlags,) ?*TrayEntry {
pub inline fn insertTrayEntryAt(traymenu: *TrayMenu, pos: c_int, label: [*c]const u8, flags: TrayEntryFlags) ?*TrayEntry {
return c.SDL_InsertTrayEntryAt(traymenu, pos, label, @bitCast(flags));
}

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

@ -130,14 +130,7 @@ pub const Window = opaque {
return @bitCast(c.SDL_GetWindowPixelFormat(window));
}
pub inline fn createPopupWindow(
window: *Window,
offset_x: c_int,
offset_y: c_int,
w: c_int,
h: c_int,
flags: WindowFlags,
) ?*Window {
pub inline fn createPopupWindow(window: *Window, offset_x: c_int, offset_y: c_int, w: c_int, h: c_int, flags: WindowFlags) ?*Window {
return c.SDL_CreatePopupWindow(window, offset_x, offset_y, w, h, @bitCast(flags));
}
@ -197,13 +190,7 @@ pub const Window = opaque {
return c.SDL_GetWindowAspectRatio(window, @ptrCast(min_aspect), @ptrCast(max_aspect));
}
pub inline fn getWindowBordersSize(
window: *Window,
top: *c_int,
left: *c_int,
bottom: *c_int,
right: *c_int,
) bool {
pub inline fn getWindowBordersSize(window: *Window, top: *c_int, left: *c_int, bottom: *c_int, right: *c_int) bool {
return c.SDL_GetWindowBordersSize(window, @ptrCast(top), @ptrCast(left), @ptrCast(bottom), @ptrCast(right));
}
@ -476,14 +463,7 @@ pub inline fn getFullscreenDisplayModes(displayID: DisplayID, count: *c_int) ?*?
return @intFromEnum(c.SDL_GetFullscreenDisplayModes(displayID, @ptrCast(count)));
}
pub inline fn getClosestFullscreenDisplayMode(
displayID: DisplayID,
w: c_int,
h: c_int,
refresh_rate: f32,
include_high_density_modes: bool,
closest: ?*DisplayMode,
) bool {
pub inline fn getClosestFullscreenDisplayMode(displayID: DisplayID, w: c_int, h: c_int, refresh_rate: f32, include_high_density_modes: bool, closest: ?*DisplayMode) bool {
return c.SDL_GetClosestFullscreenDisplayMode(displayID, w, h, refresh_rate, include_high_density_modes, @intFromEnum(closest));
}
@ -507,12 +487,7 @@ pub inline fn getWindows(count: *c_int) ?*?*Window {
return c.SDL_GetWindows(@ptrCast(count));
}
pub inline fn createWindow(
title: [*c]const u8,
w: c_int,
h: c_int,
flags: WindowFlags,
) ?*Window {
pub inline fn createWindow(title: [*c]const u8, w: c_int, h: c_int, flags: WindowFlags) ?*Window {
return c.SDL_CreateWindow(title, w, h, @bitCast(flags));
}
@ -588,12 +563,7 @@ pub inline fn egl_GetCurrentConfig() EGLConfig {
return c.SDL_EGL_GetCurrentConfig();
}
pub inline fn egl_SetAttributeCallbacks(
platformAttribCallback: EGLAttribArrayCallback,
surfaceAttribCallback: EGLIntArrayCallback,
contextAttribCallback: EGLIntArrayCallback,
userdata: ?*anyopaque,
) void {
pub inline fn egl_SetAttributeCallbacks(platformAttribCallback: EGLAttribArrayCallback, surfaceAttribCallback: EGLIntArrayCallback, contextAttribCallback: EGLIntArrayCallback, userdata: ?*anyopaque) void {
return c.SDL_EGL_SetAttributeCallbacks(platformAttribCallback, surfaceAttribCallback, contextAttribCallback, userdata);
}

View File

@ -2,7 +2,7 @@ const std = @import("std");
pub const c = @import("c.zig").c;
pub const Window = opaque {
pub inline fn vulkan_CreateSurface(window: *Window, instance: VkInstance, allocator: const struct VkAllocationCallbacks *, surface: VkSurfaceKHR *,) bool {
pub inline fn vulkan_CreateSurface(window: *Window, instance: VkInstance, allocator: const struct VkAllocationCallbacks *, surface: VkSurfaceKHR *) bool {
return c.SDL_Vulkan_CreateSurface(window, instance, allocator, surface);
}