updated generated bindings and added gpu example
This commit is contained in:
parent
d2f6fb404d
commit
1dcfa945e9
31
README.md
31
README.md
|
|
@ -9,16 +9,32 @@ A sample SDL3 application using Zig-native bindings instead of C imports.
|
||||||
- Event loop with keyboard input handling
|
- Event loop with keyboard input handling
|
||||||
- Exits on pressing Escape key
|
- Exits on pressing Escape key
|
||||||
- Basic rendering with color clear
|
- Basic rendering with color clear
|
||||||
|
- GPU-accelerated rendering sample
|
||||||
|
|
||||||
|
## Samples
|
||||||
|
|
||||||
|
### Main Sample (`src/main.zig`)
|
||||||
|
Basic SDL3 window with traditional renderer API:
|
||||||
|
```bash
|
||||||
|
zig build run
|
||||||
|
```
|
||||||
|
|
||||||
|
### GPU Sample (`src/gpu_sample.zig`)
|
||||||
|
SDL3 GPU API sample that initializes a GPU device and clears the screen with a yellowish color:
|
||||||
|
```bash
|
||||||
|
zig build run-gpu
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** The GPU sample requires SDL3 to be built with GPU backend support (Vulkan, Metal, or D3D12). If you see "No supported SDL_GPU backend found!", ensure you have the appropriate graphics drivers and SDL3 GPU support installed.
|
||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
|
|
||||||
- `src/main.zig` - Main application using Zig SDL3 bindings
|
- `src/main.zig` - Main application using Zig SDL3 bindings (traditional renderer)
|
||||||
|
- `src/gpu_sample.zig` - GPU API sample with render pass clear
|
||||||
- `sdl3-zig/` - Vendored Zig bindings for SDL3
|
- `sdl3-zig/` - Vendored Zig bindings for SDL3
|
||||||
- `sdl3.zig` - Main module that re-exports all SDL3 APIs
|
- `sdl3.zig` - Main module that re-exports all SDL3 APIs
|
||||||
- `sdl3/` - Individual API modules (init, video, events, render, etc.)
|
- `sdl3/` - Individual API modules (init, video, events, render, gpu, etc.)
|
||||||
- `sdl3/c.zig` - C import wrapper for SDL3 headers
|
- `sdl3/c.zig` - C import wrapper for SDL3 headers
|
||||||
- `build.zig` - Build configuration
|
|
||||||
- `build.zig.zon` - Package manifest
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
|
|
@ -34,10 +50,14 @@ zig build
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Run the main renderer sample
|
||||||
zig build run
|
zig build run
|
||||||
|
|
||||||
|
# Run the GPU API sample
|
||||||
|
zig build run-gpu
|
||||||
```
|
```
|
||||||
|
|
||||||
Press Escape to exit the application.
|
Press Escape to exit the applications.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|
@ -45,3 +65,4 @@ Press Escape to exit the application.
|
||||||
- The Zig bindings provide type-safe, Zig-friendly wrappers around SDL3's C API
|
- The Zig bindings provide type-safe, Zig-friendly wrappers around SDL3's C API
|
||||||
- Opaque pointer types require `@ptrCast` when crossing between binding and C types
|
- Opaque pointer types require `@ptrCast` when crossing between binding and C types
|
||||||
- All SDL3 functions are accessed through the `sdl` import (e.g., `sdl.init_fn()`, `sdl.video.createWindow()`)
|
- All SDL3 functions are accessed through the `sdl` import (e.g., `sdl.init_fn()`, `sdl.video.createWindow()`)
|
||||||
|
- GPU sample uses SDL3's new GPU API for modern graphics rendering
|
||||||
|
|
|
||||||
24
build.zig
24
build.zig
|
|
@ -45,4 +45,28 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the app");
|
const run_step = b.step("run", "Run the app");
|
||||||
run_step.dependOn(&run_cmd.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
|
// GPU Sample
|
||||||
|
const gpu_exe = b.addExecutable(.{
|
||||||
|
.name = "gpu-sample",
|
||||||
|
.root_module = b.createModule(.{
|
||||||
|
.root_source_file = b.path("src/gpu_sample.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
gpu_exe.root_module.addImport("sdl3", sdl3_module);
|
||||||
|
gpu_exe.linkLibrary(sdl_lib);
|
||||||
|
b.installArtifact(gpu_exe);
|
||||||
|
|
||||||
|
const gpu_run_cmd = b.addRunArtifact(gpu_exe);
|
||||||
|
gpu_run_cmd.step.dependOn(b.getInstallStep());
|
||||||
|
|
||||||
|
if (b.args) |args| {
|
||||||
|
gpu_run_cmd.addArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gpu_run_step = b.step("run-gpu", "Run the GPU sample");
|
||||||
|
gpu_run_step.dependOn(&gpu_run_cmd.step);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ pub const AudioStream = opaque {
|
||||||
return @bitCast(c.SDL_GetAudioStreamFormat(@ptrCast(audiostream), @ptrCast(src_spec), @ptrCast(dst_spec)));
|
return @bitCast(c.SDL_GetAudioStreamFormat(@ptrCast(audiostream), @ptrCast(src_spec), @ptrCast(dst_spec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamFormat(audiostream: *AudioStream, src_spec: *const AudioSpec, dst_spec: *const AudioSpec) bool {
|
pub inline fn setAudioStreamFormat(audiostream: *AudioStream, src_spec: ?*const AudioSpec, dst_spec: ?*const AudioSpec) bool {
|
||||||
return @bitCast(c.SDL_SetAudioStreamFormat(@ptrCast(audiostream), @ptrCast(src_spec), @ptrCast(dst_spec)));
|
return @bitCast(c.SDL_SetAudioStreamFormat(@ptrCast(audiostream), @ptrCast(src_spec), @ptrCast(dst_spec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,6 +90,10 @@ pub const AudioStream = opaque {
|
||||||
return @bitCast(c.SDL_PutAudioStreamDataNoCopy(@ptrCast(audiostream), buf, len, callback, userdata));
|
return @bitCast(c.SDL_PutAudioStreamDataNoCopy(@ptrCast(audiostream), buf, len, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub inline fn putAudioStreamPlanarData(audiostream: *AudioStream, channel_buffers: [*c]const *anyopaque, num_channels: c_int, num_samples: c_int) bool {
|
||||||
|
return @bitCast(c.SDL_PutAudioStreamPlanarData(@ptrCast(audiostream), channel_buffers, num_channels, num_samples));
|
||||||
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamData(audiostream: *AudioStream, buf: ?*anyopaque, len: c_int) c_int {
|
pub inline fn getAudioStreamData(audiostream: *AudioStream, buf: ?*anyopaque, len: c_int) c_int {
|
||||||
return c.SDL_GetAudioStreamData(@ptrCast(audiostream), buf, len);
|
return c.SDL_GetAudioStreamData(@ptrCast(audiostream), buf, len);
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +179,7 @@ pub inline fn getAudioDeviceChannelMap(devid: AudioDeviceID, count: *c_int) *c_i
|
||||||
return @ptrCast(c.SDL_GetAudioDeviceChannelMap(devid, @ptrCast(count)));
|
return @ptrCast(c.SDL_GetAudioDeviceChannelMap(devid, @ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openAudioDevice(devid: AudioDeviceID, spec: *const AudioSpec) AudioDeviceID {
|
pub inline fn openAudioDevice(devid: AudioDeviceID, spec: ?*const AudioSpec) AudioDeviceID {
|
||||||
return c.SDL_OpenAudioDevice(devid, @ptrCast(spec));
|
return c.SDL_OpenAudioDevice(devid, @ptrCast(spec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,7 +215,7 @@ pub inline fn closeAudioDevice(devid: AudioDeviceID) void {
|
||||||
return c.SDL_CloseAudioDevice(devid);
|
return c.SDL_CloseAudioDevice(devid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindAudioStreams(devid: AudioDeviceID, streams: [*c]*const AudioStream, num_streams: c_int) bool {
|
pub inline fn bindAudioStreams(devid: AudioDeviceID, streams: [*c]?*const AudioStream, num_streams: c_int) bool {
|
||||||
return @bitCast(c.SDL_BindAudioStreams(devid, streams, num_streams));
|
return @bitCast(c.SDL_BindAudioStreams(devid, streams, num_streams));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,11 +223,11 @@ pub inline fn bindAudioStream(devid: AudioDeviceID, stream: ?*AudioStream) bool
|
||||||
return @bitCast(c.SDL_BindAudioStream(devid, @ptrCast(stream)));
|
return @bitCast(c.SDL_BindAudioStream(devid, @ptrCast(stream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unbindAudioStreams(streams: [*c]*const AudioStream, num_streams: c_int) void {
|
pub inline fn unbindAudioStreams(streams: [*c]?*const AudioStream, num_streams: c_int) void {
|
||||||
return c.SDL_UnbindAudioStreams(streams, num_streams);
|
return c.SDL_UnbindAudioStreams(streams, num_streams);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createAudioStream(src_spec: *const AudioSpec, dst_spec: *const AudioSpec) ?*AudioStream {
|
pub inline fn createAudioStream(src_spec: ?*const AudioSpec, dst_spec: ?*const AudioSpec) ?*AudioStream {
|
||||||
return @ptrCast(c.SDL_CreateAudioStream(@ptrCast(src_spec), @ptrCast(dst_spec)));
|
return @ptrCast(c.SDL_CreateAudioStream(@ptrCast(src_spec), @ptrCast(dst_spec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,7 +235,7 @@ pub const AudioStreamDataCompleteCallback = c.SDL_AudioStreamDataCompleteCallbac
|
||||||
|
|
||||||
pub const AudioStreamCallback = c.SDL_AudioStreamCallback;
|
pub const AudioStreamCallback = c.SDL_AudioStreamCallback;
|
||||||
|
|
||||||
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 @ptrCast(c.SDL_OpenAudioDeviceStream(devid, @ptrCast(spec), callback, userdata));
|
return @ptrCast(c.SDL_OpenAudioDeviceStream(devid, @ptrCast(spec), callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,7 +253,7 @@ pub inline fn mixAudio(dst: [*c]u8, src: [*c]const u8, format: AudioFormat, len:
|
||||||
return @bitCast(c.SDL_MixAudio(dst, src, @bitCast(format), len, volume));
|
return @bitCast(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: [*c][*c]u8, 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: [*c][*c]u8, dst_len: *c_int) bool {
|
||||||
return @bitCast(c.SDL_ConvertAudioSamples(@ptrCast(src_spec), src_data, src_len, @ptrCast(dst_spec), dst_data, @ptrCast(dst_len)));
|
return @bitCast(c.SDL_ConvertAudioSamples(@ptrCast(src_spec), src_data, src_len, @ptrCast(dst_spec), dst_data, @ptrCast(dst_len)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ pub inline fn getCameras(count: *c_int) ?*CameraID {
|
||||||
return @ptrCast(c.SDL_GetCameras(@ptrCast(count)));
|
return @ptrCast(c.SDL_GetCameras(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraSupportedFormats(instance_id: CameraID, count: *c_int) [*c][*c]CameraSpec {
|
pub inline fn getCameraSupportedFormats(instance_id: CameraID, count: *c_int) [*c]?*CameraSpec {
|
||||||
return c.SDL_GetCameraSupportedFormats(instance_id, @ptrCast(count));
|
return c.SDL_GetCameraSupportedFormats(instance_id, @ptrCast(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,6 +128,6 @@ pub inline fn getCameraPosition(instance_id: CameraID) CameraPosition {
|
||||||
return c.SDL_GetCameraPosition(instance_id);
|
return c.SDL_GetCameraPosition(instance_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openCamera(instance_id: CameraID, spec: *const CameraSpec) ?*Camera {
|
pub inline fn openCamera(instance_id: CameraID, spec: ?*const CameraSpec) ?*Camera {
|
||||||
return @ptrCast(c.SDL_OpenCamera(instance_id, @ptrCast(spec)));
|
return @ptrCast(c.SDL_OpenCamera(instance_id, @ptrCast(spec)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@ pub const DialogFileFilter = extern struct {
|
||||||
|
|
||||||
pub const DialogFileCallback = c.SDL_DialogFileCallback;
|
pub const DialogFileCallback = c.SDL_DialogFileCallback;
|
||||||
|
|
||||||
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, @ptrCast(window), @ptrCast(filters), nfilters, default_location, @bitCast(allow_many));
|
return c.SDL_ShowOpenFileDialog(callback, userdata, @ptrCast(window), @ptrCast(filters), nfilters, default_location, @bitCast(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, @ptrCast(window), @ptrCast(filters), nfilters, default_location);
|
return c.SDL_ShowSaveFileDialog(callback, userdata, @ptrCast(window), @ptrCast(filters), nfilters, default_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -785,10 +785,10 @@ pub inline fn registerEvents(numevents: c_int) u32 {
|
||||||
return c.SDL_RegisterEvents(numevents);
|
return c.SDL_RegisterEvents(numevents);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFromEvent(event: *const Event) ?*Window {
|
pub inline fn getWindowFromEvent(event: ?*const Event) ?*Window {
|
||||||
return @ptrCast(c.SDL_GetWindowFromEvent(@ptrCast(event)));
|
return @ptrCast(c.SDL_GetWindowFromEvent(@ptrCast(event)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getEventDescription(event: *const Event, buf: [*c]u8, buflen: c_int) c_int {
|
pub inline fn getEventDescription(event: ?*const Event, buf: [*c]u8, buflen: c_int) c_int {
|
||||||
return c.SDL_GetEventDescription(@ptrCast(event), buf, buflen);
|
return c.SDL_GetEventDescription(@ptrCast(event), buf, buflen);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ pub const Gamepad = opaque {
|
||||||
return @ptrCast(c.SDL_GetGamepadJoystick(@ptrCast(gamepad)));
|
return @ptrCast(c.SDL_GetGamepadJoystick(@ptrCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadBindings(gamepad: *Gamepad, count: *c_int) [*c][*c]GamepadBinding {
|
pub inline fn getGamepadBindings(gamepad: *Gamepad, count: *c_int) [*c]?*GamepadBinding {
|
||||||
return c.SDL_GetGamepadBindings(@ptrCast(gamepad), @ptrCast(count));
|
return c.SDL_GetGamepadBindings(@ptrCast(gamepad), @ptrCast(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,31 +58,31 @@ pub const GPUDevice = opaque {
|
||||||
return c.SDL_GetGPUDeviceProperties(@ptrCast(gpudevice));
|
return c.SDL_GetGPUDeviceProperties(@ptrCast(gpudevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUComputePipeline(gpudevice: *GPUDevice, createinfo: *const GPUComputePipelineCreateInfo) ?*GPUComputePipeline {
|
pub inline fn createGPUComputePipeline(gpudevice: *GPUDevice, createinfo: ?*const GPUComputePipelineCreateInfo) ?*GPUComputePipeline {
|
||||||
return @ptrCast(c.SDL_CreateGPUComputePipeline(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(c.SDL_CreateGPUComputePipeline(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUGraphicsPipeline(gpudevice: *GPUDevice, createinfo: *const GPUGraphicsPipelineCreateInfo) ?*GPUGraphicsPipeline {
|
pub inline fn createGPUGraphicsPipeline(gpudevice: *GPUDevice, createinfo: ?*const GPUGraphicsPipelineCreateInfo) ?*GPUGraphicsPipeline {
|
||||||
return @ptrCast(c.SDL_CreateGPUGraphicsPipeline(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(c.SDL_CreateGPUGraphicsPipeline(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUSampler(gpudevice: *GPUDevice, createinfo: *const GPUSamplerCreateInfo) ?*GPUSampler {
|
pub inline fn createGPUSampler(gpudevice: *GPUDevice, createinfo: ?*const GPUSamplerCreateInfo) ?*GPUSampler {
|
||||||
return @ptrCast(c.SDL_CreateGPUSampler(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(c.SDL_CreateGPUSampler(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUShader(gpudevice: *GPUDevice, createinfo: *const GPUShaderCreateInfo) ?*GPUShader {
|
pub inline fn createGPUShader(gpudevice: *GPUDevice, createinfo: ?*const GPUShaderCreateInfo) ?*GPUShader {
|
||||||
return @ptrCast(c.SDL_CreateGPUShader(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(c.SDL_CreateGPUShader(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUTexture(gpudevice: *GPUDevice, createinfo: *const GPUTextureCreateInfo) ?*GPUTexture {
|
pub inline fn createGPUTexture(gpudevice: *GPUDevice, createinfo: ?*const GPUTextureCreateInfo) ?*GPUTexture {
|
||||||
return @ptrCast(c.SDL_CreateGPUTexture(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(c.SDL_CreateGPUTexture(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUBuffer(gpudevice: *GPUDevice, createinfo: *const GPUBufferCreateInfo) ?*GPUBuffer {
|
pub inline fn createGPUBuffer(gpudevice: *GPUDevice, createinfo: ?*const GPUBufferCreateInfo) ?*GPUBuffer {
|
||||||
return @ptrCast(c.SDL_CreateGPUBuffer(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(c.SDL_CreateGPUBuffer(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUTransferBuffer(gpudevice: *GPUDevice, createinfo: *const GPUTransferBufferCreateInfo) ?*GPUTransferBuffer {
|
pub inline fn createGPUTransferBuffer(gpudevice: *GPUDevice, createinfo: ?*const GPUTransferBufferCreateInfo) ?*GPUTransferBuffer {
|
||||||
return @ptrCast(c.SDL_CreateGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
return @ptrCast(c.SDL_CreateGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ pub const GPUDevice = opaque {
|
||||||
return @bitCast(c.SDL_WaitForGPUIdle(@ptrCast(gpudevice)));
|
return @bitCast(c.SDL_WaitForGPUIdle(@ptrCast(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 @bitCast(c.SDL_WaitForGPUFences(@ptrCast(gpudevice), @bitCast(wait_all), fences, num_fences));
|
return @bitCast(c.SDL_WaitForGPUFences(@ptrCast(gpudevice), @bitCast(wait_all), fences, num_fences));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,11 +238,11 @@ pub const GPUCommandBuffer = opaque {
|
||||||
return c.SDL_PushGPUComputeUniformData(@ptrCast(gpucommandbuffer), slot_index, data, length);
|
return c.SDL_PushGPUComputeUniformData(@ptrCast(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 @ptrCast(c.SDL_BeginGPURenderPass(@ptrCast(gpucommandbuffer), @ptrCast(color_target_infos), num_color_targets, @ptrCast(depth_stencil_target_info)));
|
return @ptrCast(c.SDL_BeginGPURenderPass(@ptrCast(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 @ptrCast(c.SDL_BeginGPUComputePass(@ptrCast(gpucommandbuffer), @ptrCast(storage_texture_bindings), num_storage_texture_bindings, @ptrCast(storage_buffer_bindings), num_storage_buffer_bindings));
|
return @ptrCast(c.SDL_BeginGPUComputePass(@ptrCast(gpucommandbuffer), @ptrCast(storage_texture_bindings), num_storage_texture_bindings, @ptrCast(storage_buffer_bindings), num_storage_buffer_bindings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,15 +254,15 @@ pub const GPUCommandBuffer = opaque {
|
||||||
return c.SDL_GenerateMipmapsForGPUTexture(@ptrCast(gpucommandbuffer), @ptrCast(texture));
|
return c.SDL_GenerateMipmapsForGPUTexture(@ptrCast(gpucommandbuffer), @ptrCast(texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn blitGPUTexture(gpucommandbuffer: *GPUCommandBuffer, info: *const GPUBlitInfo) void {
|
pub inline fn blitGPUTexture(gpucommandbuffer: *GPUCommandBuffer, info: ?*const GPUBlitInfo) void {
|
||||||
return c.SDL_BlitGPUTexture(@ptrCast(gpucommandbuffer), @ptrCast(info));
|
return c.SDL_BlitGPUTexture(@ptrCast(gpucommandbuffer), @ptrCast(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn acquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: [*c][*c]GPUTexture, swapchain_texture_width: *u32, swapchain_texture_height: *u32) bool {
|
pub inline fn acquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: [*c]?*GPUTexture, swapchain_texture_width: *u32, swapchain_texture_height: *u32) bool {
|
||||||
return @bitCast(c.SDL_AcquireGPUSwapchainTexture(@ptrCast(gpucommandbuffer), @ptrCast(window), swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height)));
|
return @bitCast(c.SDL_AcquireGPUSwapchainTexture(@ptrCast(gpucommandbuffer), @ptrCast(window), swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitAndAcquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: [*c][*c]GPUTexture, swapchain_texture_width: *u32, swapchain_texture_height: *u32) bool {
|
pub inline fn waitAndAcquireGPUSwapchainTexture(gpucommandbuffer: *GPUCommandBuffer, window: ?*Window, swapchain_texture: [*c]?*GPUTexture, swapchain_texture_width: *u32, swapchain_texture_height: *u32) bool {
|
||||||
return @bitCast(c.SDL_WaitAndAcquireGPUSwapchainTexture(@ptrCast(gpucommandbuffer), @ptrCast(window), swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height)));
|
return @bitCast(c.SDL_WaitAndAcquireGPUSwapchainTexture(@ptrCast(gpucommandbuffer), @ptrCast(window), swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,11 +284,11 @@ pub const GPURenderPass = opaque {
|
||||||
return c.SDL_BindGPUGraphicsPipeline(@ptrCast(gpurenderpass), @ptrCast(graphics_pipeline));
|
return c.SDL_BindGPUGraphicsPipeline(@ptrCast(gpurenderpass), @ptrCast(graphics_pipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUViewport(gpurenderpass: *GPURenderPass, viewport: *const GPUViewport) void {
|
pub inline fn setGPUViewport(gpurenderpass: *GPURenderPass, viewport: ?*const GPUViewport) void {
|
||||||
return c.SDL_SetGPUViewport(@ptrCast(gpurenderpass), @ptrCast(viewport));
|
return c.SDL_SetGPUViewport(@ptrCast(gpurenderpass), @ptrCast(viewport));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUScissor(gpurenderpass: *GPURenderPass, scissor: *const Rect) void {
|
pub inline fn setGPUScissor(gpurenderpass: *GPURenderPass, scissor: ?*const Rect) void {
|
||||||
return c.SDL_SetGPUScissor(@ptrCast(gpurenderpass), @ptrCast(scissor));
|
return c.SDL_SetGPUScissor(@ptrCast(gpurenderpass), @ptrCast(scissor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -300,35 +300,35 @@ pub const GPURenderPass = opaque {
|
||||||
return c.SDL_SetGPUStencilReference(@ptrCast(gpurenderpass), reference);
|
return c.SDL_SetGPUStencilReference(@ptrCast(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(@ptrCast(gpurenderpass), first_slot, @ptrCast(bindings), num_bindings);
|
return c.SDL_BindGPUVertexBuffers(@ptrCast(gpurenderpass), first_slot, @ptrCast(bindings), num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindGPUIndexBuffer(gpurenderpass: *GPURenderPass, binding: *const GPUBufferBinding, index_element_size: GPUIndexElementSize) void {
|
pub inline fn bindGPUIndexBuffer(gpurenderpass: *GPURenderPass, binding: ?*const GPUBufferBinding, index_element_size: GPUIndexElementSize) void {
|
||||||
return c.SDL_BindGPUIndexBuffer(@ptrCast(gpurenderpass), @ptrCast(binding), index_element_size);
|
return c.SDL_BindGPUIndexBuffer(@ptrCast(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(@ptrCast(gpurenderpass), first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
|
return c.SDL_BindGPUVertexSamplers(@ptrCast(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(@ptrCast(gpurenderpass), first_slot, storage_textures, num_bindings);
|
return c.SDL_BindGPUVertexStorageTextures(@ptrCast(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(@ptrCast(gpurenderpass), first_slot, storage_buffers, num_bindings);
|
return c.SDL_BindGPUVertexStorageBuffers(@ptrCast(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(@ptrCast(gpurenderpass), first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
|
return c.SDL_BindGPUFragmentSamplers(@ptrCast(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(@ptrCast(gpurenderpass), first_slot, storage_textures, num_bindings);
|
return c.SDL_BindGPUFragmentStorageTextures(@ptrCast(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(@ptrCast(gpurenderpass), first_slot, storage_buffers, num_bindings);
|
return c.SDL_BindGPUFragmentStorageBuffers(@ptrCast(gpurenderpass), first_slot, storage_buffers, num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -358,15 +358,15 @@ pub const GPUComputePass = opaque {
|
||||||
return c.SDL_BindGPUComputePipeline(@ptrCast(gpucomputepass), @ptrCast(compute_pipeline));
|
return c.SDL_BindGPUComputePipeline(@ptrCast(gpucomputepass), @ptrCast(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(@ptrCast(gpucomputepass), first_slot, @ptrCast(texture_sampler_bindings), num_bindings);
|
return c.SDL_BindGPUComputeSamplers(@ptrCast(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(@ptrCast(gpucomputepass), first_slot, storage_textures, num_bindings);
|
return c.SDL_BindGPUComputeStorageTextures(@ptrCast(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(@ptrCast(gpucomputepass), first_slot, storage_buffers, num_bindings);
|
return c.SDL_BindGPUComputeStorageBuffers(@ptrCast(gpucomputepass), first_slot, storage_buffers, num_bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -384,27 +384,27 @@ pub const GPUComputePass = opaque {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUCopyPass = 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(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), @bitCast(cycle));
|
return c.SDL_UploadToGPUTexture(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), @bitCast(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(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), @bitCast(cycle));
|
return c.SDL_UploadToGPUBuffer(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), @bitCast(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(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), w, h, d, @bitCast(cycle));
|
return c.SDL_CopyGPUTextureToTexture(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), w, h, d, @bitCast(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(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), size, @bitCast(cycle));
|
return c.SDL_CopyGPUBufferToBuffer(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination), size, @bitCast(cycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn downloadFromGPUTexture(gpucopypass: *GPUCopyPass, source: *const GPUTextureRegion, destination: *const GPUTextureTransferInfo) void {
|
pub inline fn downloadFromGPUTexture(gpucopypass: *GPUCopyPass, source: ?*const GPUTextureRegion, destination: ?*const GPUTextureTransferInfo) void {
|
||||||
return c.SDL_DownloadFromGPUTexture(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination));
|
return c.SDL_DownloadFromGPUTexture(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn downloadFromGPUBuffer(gpucopypass: *GPUCopyPass, source: *const GPUBufferRegion, destination: *const GPUTransferBufferLocation) void {
|
pub inline fn downloadFromGPUBuffer(gpucopypass: *GPUCopyPass, source: ?*const GPUBufferRegion, destination: ?*const GPUTransferBufferLocation) void {
|
||||||
return c.SDL_DownloadFromGPUBuffer(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination));
|
return c.SDL_DownloadFromGPUBuffer(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -610,7 +610,18 @@ pub const GPUShaderStage = enum(c_int) {
|
||||||
shaderstageFragment,
|
shaderstageFragment,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUShaderFormat = u32;
|
pub const GPUShaderFormat = packed struct(u32) {
|
||||||
|
shaderformatPrivate: bool = false, // Shaders for NDA'd platforms.
|
||||||
|
shaderformatSpirv: bool = false, // SPIR-V shaders for Vulkan.
|
||||||
|
shaderformatDxbc: bool = false, // DXBC SM5_1 shaders for D3D12.
|
||||||
|
shaderformatDxil: bool = false, // DXIL SM6_0 shaders for D3D12.
|
||||||
|
shaderformatMsl: bool = false, // MSL shaders for Metal.
|
||||||
|
shaderformatMetallib: bool = false, // Precompiled metallib shaders for Metal.
|
||||||
|
pad0: u25 = 0,
|
||||||
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = GPUShaderFormat{};
|
||||||
|
};
|
||||||
|
|
||||||
pub const GPUVertexElementFormat = enum(c_int) {
|
pub const GPUVertexElementFormat = enum(c_int) {
|
||||||
vertexelementformatInvalid,
|
vertexelementformatInvalid,
|
||||||
|
|
@ -875,9 +886,9 @@ pub const GPUVertexAttribute = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUVertexInputState = extern struct {
|
pub const GPUVertexInputState = extern struct {
|
||||||
vertex_buffer_descriptions: *const GPUVertexBufferDescription, // A pointer to an array of vertex buffer descriptions.
|
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.
|
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.
|
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.
|
num_vertex_attributes: u32, // The number of vertex attribute descriptions in the above array.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -981,7 +992,7 @@ pub const GPUColorTargetDescription = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUGraphicsPipelineTargetInfo = extern struct {
|
pub const GPUGraphicsPipelineTargetInfo = extern struct {
|
||||||
color_target_descriptions: *const GPUColorTargetDescription, // A pointer to an array of color target descriptions.
|
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.
|
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.
|
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.
|
has_depth_stencil_target: bool, // true specifies that the pipeline uses a depth-stencil target.
|
||||||
|
|
|
||||||
|
|
@ -40,15 +40,15 @@ pub const Haptic = opaque {
|
||||||
return c.SDL_GetNumHapticAxes(@ptrCast(haptic));
|
return c.SDL_GetNumHapticAxes(@ptrCast(haptic));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hapticEffectSupported(haptic: *Haptic, effect: *const HapticEffect) bool {
|
pub inline fn hapticEffectSupported(haptic: *Haptic, effect: ?*const HapticEffect) bool {
|
||||||
return @bitCast(c.SDL_HapticEffectSupported(@ptrCast(haptic), @ptrCast(effect)));
|
return @bitCast(c.SDL_HapticEffectSupported(@ptrCast(haptic), @ptrCast(effect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createHapticEffect(haptic: *Haptic, effect: *const HapticEffect) HapticEffectID {
|
pub inline fn createHapticEffect(haptic: *Haptic, effect: ?*const HapticEffect) HapticEffectID {
|
||||||
return c.SDL_CreateHapticEffect(@ptrCast(haptic), @ptrCast(effect));
|
return c.SDL_CreateHapticEffect(@ptrCast(haptic), @ptrCast(effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateHapticEffect(haptic: *Haptic, effect: HapticEffectID, data: *const HapticEffect) bool {
|
pub inline fn updateHapticEffect(haptic: *Haptic, effect: HapticEffectID, data: ?*const HapticEffect) bool {
|
||||||
return @bitCast(c.SDL_UpdateHapticEffect(@ptrCast(haptic), effect, @ptrCast(data)));
|
return @bitCast(c.SDL_UpdateHapticEffect(@ptrCast(haptic), effect, @ptrCast(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -280,8 +280,8 @@ pub const VirtualJoystickDesc = extern struct {
|
||||||
nsensors: u16, // the number of sensors on this joystick, requires `sensors` to point at valid descriptions
|
nsensors: u16, // the number of sensors on this joystick, requires `sensors` to point at valid descriptions
|
||||||
padding2: [2]u16, // unused
|
padding2: [2]u16, // unused
|
||||||
name: [*c]const u8, // the name of the joystick
|
name: [*c]const u8, // the name of the joystick
|
||||||
touchpads: *const VirtualJoystickTouchpadDesc, // A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0
|
touchpads: ?*const VirtualJoystickTouchpadDesc, // A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0
|
||||||
sensors: *const VirtualJoystickSensorDesc, // A pointer to an array of sensor descriptions, required if `nsensors` is > 0
|
sensors: ?*const VirtualJoystickSensorDesc, // A pointer to an array of sensor descriptions, required if `nsensors` is > 0
|
||||||
userdata: ?*anyopaque, // User data pointer passed to callbacks
|
userdata: ?*anyopaque, // User data pointer passed to callbacks
|
||||||
Update: ?*const anyopaque, // Called when the joystick state should be updated
|
Update: ?*const anyopaque, // Called when the joystick state should be updated
|
||||||
SetPlayerIndex: ?*const anyopaque, // Called when the player index is set
|
SetPlayerIndex: ?*const anyopaque, // Called when the player index is set
|
||||||
|
|
@ -293,7 +293,7 @@ pub const VirtualJoystickDesc = extern struct {
|
||||||
Cleanup: ?*const anyopaque, // Cleans up the userdata when the joystick is detached
|
Cleanup: ?*const anyopaque, // Cleans up the userdata when the joystick is detached
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn attachVirtualJoystick(desc: *const VirtualJoystickDesc) JoystickID {
|
pub inline fn attachVirtualJoystick(desc: ?*const VirtualJoystickDesc) JoystickID {
|
||||||
return c.SDL_AttachVirtualJoystick(@ptrCast(desc));
|
return c.SDL_AttachVirtualJoystick(@ptrCast(desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,11 @@ pub const MessageBoxData = extern struct {
|
||||||
title: [*c]const u8, // UTF-8 title
|
title: [*c]const u8, // UTF-8 title
|
||||||
message: [*c]const u8, // UTF-8 message text
|
message: [*c]const u8, // UTF-8 message text
|
||||||
numbuttons: c_int,
|
numbuttons: c_int,
|
||||||
buttons: *const MessageBoxButtonData,
|
buttons: ?*const MessageBoxButtonData,
|
||||||
colorScheme: *const MessageBoxColorScheme, // SDL_MessageBoxColorScheme, can be NULL to use system settings
|
colorScheme: ?*const MessageBoxColorScheme, // SDL_MessageBoxColorScheme, can be NULL to use system settings
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn showMessageBox(messageboxdata: *const MessageBoxData, buttonid: *c_int) bool {
|
pub inline fn showMessageBox(messageboxdata: ?*const MessageBoxData, buttonid: *c_int) bool {
|
||||||
return @bitCast(c.SDL_ShowMessageBox(@ptrCast(messageboxdata), @ptrCast(buttonid)));
|
return @bitCast(c.SDL_ShowMessageBox(@ptrCast(messageboxdata), @ptrCast(buttonid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ pub inline fn getPixelFormatForMasks(bpp: c_int, Rmask: u32, Gmask: u32, Bmask:
|
||||||
return @bitCast(c.SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask));
|
return @bitCast(c.SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPixelFormatDetails(format: PixelFormat) *const PixelFormatDetails {
|
pub inline fn getPixelFormatDetails(format: PixelFormat) ?*const PixelFormatDetails {
|
||||||
return @ptrCast(c.SDL_GetPixelFormatDetails(@bitCast(format)));
|
return @ptrCast(c.SDL_GetPixelFormatDetails(@bitCast(format)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@ pub inline fn createPalette(ncolors: c_int) ?*Palette {
|
||||||
return @ptrCast(c.SDL_CreatePalette(ncolors));
|
return @ptrCast(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 @bitCast(c.SDL_SetPaletteColors(@ptrCast(palette), @ptrCast(colors), firstcolor, ncolors));
|
return @bitCast(c.SDL_SetPaletteColors(@ptrCast(palette), @ptrCast(colors), firstcolor, ncolors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,18 +222,18 @@ pub inline fn destroyPalette(palette: ?*Palette) void {
|
||||||
return c.SDL_DestroyPalette(@ptrCast(palette));
|
return c.SDL_DestroyPalette(@ptrCast(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);
|
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);
|
return c.SDL_MapRGBA(@ptrCast(format), @ptrCast(palette), r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRGB(pixelvalue: u32, format: *const PixelFormatDetails, palette: *const Palette, r: [*c]u8, g: [*c]u8, b: [*c]u8) void {
|
pub inline fn getRGB(pixelvalue: u32, format: ?*const PixelFormatDetails, palette: ?*const Palette, r: [*c]u8, g: [*c]u8, b: [*c]u8) void {
|
||||||
return c.SDL_GetRGB(pixelvalue, @ptrCast(format), @ptrCast(palette), r, g, b);
|
return c.SDL_GetRGB(pixelvalue, @ptrCast(format), @ptrCast(palette), r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRGBA(pixelvalue: u32, format: *const PixelFormatDetails, palette: *const Palette, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) void {
|
pub inline fn getRGBA(pixelvalue: u32, format: ?*const PixelFormatDetails, palette: ?*const Palette, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) void {
|
||||||
return c.SDL_GetRGBA(pixelvalue, @ptrCast(format), @ptrCast(palette), r, g, b, a);
|
return c.SDL_GetRGBA(pixelvalue, @ptrCast(format), @ptrCast(palette), r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,42 +25,42 @@ pub const FRect = extern struct {
|
||||||
h: f32,
|
h: f32,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn hasRectIntersection(A: *const Rect, B: *const Rect) bool {
|
pub inline fn hasRectIntersection(A: ?*const Rect, B: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_HasRectIntersection(@ptrCast(A), @ptrCast(B)));
|
return @bitCast(c.SDL_HasRectIntersection(@ptrCast(A), @ptrCast(B)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectIntersection(A: *const Rect, B: *const Rect, result: ?*Rect) bool {
|
pub inline fn getRectIntersection(A: ?*const Rect, B: ?*const Rect, result: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetRectIntersection(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectIntersection(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectUnion(A: *const Rect, B: *const Rect, result: ?*Rect) bool {
|
pub inline fn getRectUnion(A: ?*const Rect, B: ?*const Rect, result: ?*Rect) bool {
|
||||||
return @bitCast(c.SDL_GetRectUnion(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectUnion(@ptrCast(A), @ptrCast(B), @ptrCast(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 @bitCast(c.SDL_GetRectEnclosingPoints(@ptrCast(points), count, @ptrCast(clip), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectEnclosingPoints(@ptrCast(points), count, @ptrCast(clip), @ptrCast(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 @bitCast(c.SDL_GetRectAndLineIntersection(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2)));
|
return @bitCast(c.SDL_GetRectAndLineIntersection(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasRectIntersectionFloat(A: *const FRect, B: *const FRect) bool {
|
pub inline fn hasRectIntersectionFloat(A: ?*const FRect, B: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_HasRectIntersectionFloat(@ptrCast(A), @ptrCast(B)));
|
return @bitCast(c.SDL_HasRectIntersectionFloat(@ptrCast(A), @ptrCast(B)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectIntersectionFloat(A: *const FRect, B: *const FRect, result: ?*FRect) bool {
|
pub inline fn getRectIntersectionFloat(A: ?*const FRect, B: ?*const FRect, result: ?*FRect) bool {
|
||||||
return @bitCast(c.SDL_GetRectIntersectionFloat(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectIntersectionFloat(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRectUnionFloat(A: *const FRect, B: *const FRect, result: ?*FRect) bool {
|
pub inline fn getRectUnionFloat(A: ?*const FRect, B: ?*const FRect, result: ?*FRect) bool {
|
||||||
return @bitCast(c.SDL_GetRectUnionFloat(@ptrCast(A), @ptrCast(B), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectUnionFloat(@ptrCast(A), @ptrCast(B), @ptrCast(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 @bitCast(c.SDL_GetRectEnclosingPointsFloat(@ptrCast(points), count, @ptrCast(clip), @ptrCast(result)));
|
return @bitCast(c.SDL_GetRectEnclosingPointsFloat(@ptrCast(points), count, @ptrCast(clip), @ptrCast(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 @bitCast(c.SDL_GetRectAndLineIntersectionFloat(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2)));
|
return @bitCast(c.SDL_GetRectAndLineIntersectionFloat(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -938,7 +938,7 @@ pub const Renderer = opaque {
|
||||||
return @bitCast(c.SDL_ConvertEventToRenderCoordinates(@ptrCast(renderer), @ptrCast(event)));
|
return @bitCast(c.SDL_ConvertEventToRenderCoordinates(@ptrCast(renderer), @ptrCast(event)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderViewport(renderer: *Renderer, rect: *const Rect) bool {
|
pub inline fn setRenderViewport(renderer: *Renderer, rect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_SetRenderViewport(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_SetRenderViewport(@ptrCast(renderer), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -954,7 +954,7 @@ pub const Renderer = opaque {
|
||||||
return @bitCast(c.SDL_GetRenderSafeArea(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_GetRenderSafeArea(@ptrCast(renderer), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setRenderClipRect(renderer: *Renderer, rect: *const Rect) bool {
|
pub inline fn setRenderClipRect(renderer: *Renderer, rect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_SetRenderClipRect(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_SetRenderClipRect(@ptrCast(renderer), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1014,7 +1014,7 @@ pub const Renderer = opaque {
|
||||||
return @bitCast(c.SDL_RenderPoint(@ptrCast(renderer), x, y));
|
return @bitCast(c.SDL_RenderPoint(@ptrCast(renderer), x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderPoints(renderer: *Renderer, points: *const FPoint, count: c_int) bool {
|
pub inline fn renderPoints(renderer: *Renderer, points: ?*const FPoint, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderPoints(@ptrCast(renderer), @ptrCast(points), count));
|
return @bitCast(c.SDL_RenderPoints(@ptrCast(renderer), @ptrCast(points), count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1022,55 +1022,55 @@ pub const Renderer = opaque {
|
||||||
return @bitCast(c.SDL_RenderLine(@ptrCast(renderer), x1, y1, x2, y2));
|
return @bitCast(c.SDL_RenderLine(@ptrCast(renderer), x1, y1, x2, y2));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderLines(renderer: *Renderer, points: *const FPoint, count: c_int) bool {
|
pub inline fn renderLines(renderer: *Renderer, points: ?*const FPoint, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderLines(@ptrCast(renderer), @ptrCast(points), count));
|
return @bitCast(c.SDL_RenderLines(@ptrCast(renderer), @ptrCast(points), count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderRect(renderer: *Renderer, rect: *const FRect) bool {
|
pub inline fn renderRect(renderer: *Renderer, rect: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_RenderRect(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_RenderRect(@ptrCast(renderer), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderRects(renderer: *Renderer, rects: *const FRect, count: c_int) bool {
|
pub inline fn renderRects(renderer: *Renderer, rects: ?*const FRect, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderRects(@ptrCast(renderer), @ptrCast(rects), count));
|
return @bitCast(c.SDL_RenderRects(@ptrCast(renderer), @ptrCast(rects), count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderFillRect(renderer: *Renderer, rect: *const FRect) bool {
|
pub inline fn renderFillRect(renderer: *Renderer, rect: ?*const FRect) bool {
|
||||||
return @bitCast(c.SDL_RenderFillRect(@ptrCast(renderer), @ptrCast(rect)));
|
return @bitCast(c.SDL_RenderFillRect(@ptrCast(renderer), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderFillRects(renderer: *Renderer, rects: *const FRect, count: c_int) bool {
|
pub inline fn renderFillRects(renderer: *Renderer, rects: ?*const FRect, count: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderFillRects(@ptrCast(renderer), @ptrCast(rects), count));
|
return @bitCast(c.SDL_RenderFillRects(@ptrCast(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 @bitCast(c.SDL_RenderTexture(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_RenderTexture(@ptrCast(renderer), @ptrCast(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 @bitCast(c.SDL_RenderTextureRotated(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(dstrect), angle, @ptrCast(center), @intFromEnum(flip)));
|
return @bitCast(c.SDL_RenderTextureRotated(@ptrCast(renderer), @ptrCast(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 @bitCast(c.SDL_RenderTextureAffine(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(origin), @ptrCast(right), @ptrCast(down)));
|
return @bitCast(c.SDL_RenderTextureAffine(@ptrCast(renderer), @ptrCast(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 @bitCast(c.SDL_RenderTextureTiled(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), scale, @ptrCast(dstrect)));
|
return @bitCast(c.SDL_RenderTextureTiled(@ptrCast(renderer), @ptrCast(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 @bitCast(c.SDL_RenderTexture9Grid(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect)));
|
return @bitCast(c.SDL_RenderTexture9Grid(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderTexture9GridTiled(renderer: *Renderer, texture: ?*Texture, srcrect: *const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: *const FRect, tileScale: f32) bool {
|
pub inline fn renderTexture9GridTiled(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: ?*const FRect, tileScale: f32) bool {
|
||||||
return @bitCast(c.SDL_RenderTexture9GridTiled(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect), tileScale));
|
return @bitCast(c.SDL_RenderTexture9GridTiled(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect), tileScale));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderGeometry(renderer: *Renderer, texture: ?*Texture, vertices: *const Vertex, num_vertices: c_int, indices: [*c]const c_int, num_indices: c_int) bool {
|
pub inline fn renderGeometry(renderer: *Renderer, texture: ?*Texture, vertices: ?*const Vertex, num_vertices: c_int, indices: [*c]const c_int, num_indices: c_int) bool {
|
||||||
return @bitCast(c.SDL_RenderGeometry(@ptrCast(renderer), @ptrCast(texture), @ptrCast(vertices), num_vertices, indices, num_indices));
|
return @bitCast(c.SDL_RenderGeometry(@ptrCast(renderer), @ptrCast(texture), @ptrCast(vertices), num_vertices, indices, num_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 {
|
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 @bitCast(c.SDL_RenderGeometryRaw(@ptrCast(renderer), @ptrCast(texture), @ptrCast(xy), xy_stride, @ptrCast(color), color_stride, @ptrCast(uv), uv_stride, num_vertices, indices, num_indices, size_indices));
|
return @bitCast(c.SDL_RenderGeometryRaw(@ptrCast(renderer), @ptrCast(texture), @ptrCast(xy), xy_stride, @ptrCast(color), color_stride, @ptrCast(uv), uv_stride, num_vertices, indices, num_indices, size_indices));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1082,7 +1082,7 @@ pub const Renderer = opaque {
|
||||||
return @bitCast(c.SDL_GetRenderTextureAddressMode(@ptrCast(renderer), @ptrCast(u_mode), @ptrCast(v_mode)));
|
return @bitCast(c.SDL_GetRenderTextureAddressMode(@ptrCast(renderer), @ptrCast(u_mode), @ptrCast(v_mode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renderReadPixels(renderer: *Renderer, rect: *const Rect) ?*Surface {
|
pub inline fn renderReadPixels(renderer: *Renderer, rect: ?*const Rect) ?*Surface {
|
||||||
return @ptrCast(c.SDL_RenderReadPixels(@ptrCast(renderer), @ptrCast(rect)));
|
return @ptrCast(c.SDL_RenderReadPixels(@ptrCast(renderer), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1208,23 +1208,23 @@ pub const Texture = opaque {
|
||||||
return @bitCast(c.SDL_GetTextureScaleMode(@ptrCast(texture), @ptrCast(scaleMode)));
|
return @bitCast(c.SDL_GetTextureScaleMode(@ptrCast(texture), @ptrCast(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 @bitCast(c.SDL_UpdateTexture(@ptrCast(texture), @ptrCast(rect), pixels, pitch));
|
return @bitCast(c.SDL_UpdateTexture(@ptrCast(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 @bitCast(c.SDL_UpdateYUVTexture(@ptrCast(texture), @ptrCast(rect), Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch));
|
return @bitCast(c.SDL_UpdateYUVTexture(@ptrCast(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 @bitCast(c.SDL_UpdateNVTexture(@ptrCast(texture), @ptrCast(rect), Yplane, Ypitch, UVplane, UVpitch));
|
return @bitCast(c.SDL_UpdateNVTexture(@ptrCast(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 @bitCast(c.SDL_LockTexture(@ptrCast(texture), @ptrCast(rect), pixels, @ptrCast(pitch)));
|
return @bitCast(c.SDL_LockTexture(@ptrCast(texture), @ptrCast(rect), pixels, @ptrCast(pitch)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn lockTextureToSurface(texture: *Texture, rect: *const Rect, surface: [*c][*c]Surface) bool {
|
pub inline fn lockTextureToSurface(texture: *Texture, rect: ?*const Rect, surface: [*c]?*Surface) bool {
|
||||||
return @bitCast(c.SDL_LockTextureToSurface(@ptrCast(texture), @ptrCast(rect), surface));
|
return @bitCast(c.SDL_LockTextureToSurface(@ptrCast(texture), @ptrCast(rect), surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1245,7 +1245,7 @@ pub inline fn getRenderDriver(index: c_int) [*c]const u8 {
|
||||||
return c.SDL_GetRenderDriver(index);
|
return c.SDL_GetRenderDriver(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createWindowAndRenderer(title: [*c]const u8, width: c_int, height: c_int, window_flags: WindowFlags, window: [*c][*c]Window, renderer: [*c][*c]Renderer) bool {
|
pub inline fn createWindowAndRenderer(title: [*c]const u8, width: c_int, height: c_int, window_flags: WindowFlags, window: [*c]?*Window, renderer: [*c]?*Renderer) bool {
|
||||||
return @bitCast(c.SDL_CreateWindowAndRenderer(title, width, height, @bitCast(window_flags), window, renderer));
|
return @bitCast(c.SDL_CreateWindowAndRenderer(title, width, height, @bitCast(window_flags), window, renderer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1256,11 +1256,11 @@ pub inline fn createRendererWithProperties(props: PropertiesID) ?*Renderer {
|
||||||
pub const GPURenderStateCreateInfo = extern struct {
|
pub const GPURenderStateCreateInfo = extern struct {
|
||||||
fragment_shader: ?*GPUShader, // The fragment shader to use when this render state is active
|
fragment_shader: ?*GPUShader, // The fragment shader to use when this render state is active
|
||||||
num_sampler_bindings: i32, // The number of additional fragment samplers to bind when this render state is active
|
num_sampler_bindings: i32, // The number of additional fragment samplers to bind when this render state is active
|
||||||
sampler_bindings: *const GPUTextureSamplerBinding, // Additional fragment samplers to bind when this render state is active
|
sampler_bindings: ?*const GPUTextureSamplerBinding, // Additional fragment samplers to bind when this render state is active
|
||||||
num_storage_textures: i32, // The number of storage textures to bind when this render state is active
|
num_storage_textures: i32, // The number of storage textures to bind when this render state is active
|
||||||
storage_textures: [*c]*const GPUTexture, // Storage textures to bind when this render state is active
|
storage_textures: [*c]?*const GPUTexture, // Storage textures to bind when this render state is active
|
||||||
num_storage_buffers: i32, // The number of storage buffers to bind when this render state is active
|
num_storage_buffers: i32, // The number of storage buffers to bind when this render state is active
|
||||||
storage_buffers: [*c]*const GPUBuffer, // Storage buffers to bind when this render state is active
|
storage_buffers: [*c]?*const GPUBuffer, // Storage buffers to bind when this render state is active
|
||||||
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,6 @@ pub inline fn openFileStorage(path: [*c]const u8) ?*Storage {
|
||||||
return @ptrCast(c.SDL_OpenFileStorage(path));
|
return @ptrCast(c.SDL_OpenFileStorage(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openStorage(iface: *const StorageInterface, userdata: ?*anyopaque) ?*Storage {
|
pub inline fn openStorage(iface: ?*const StorageInterface, userdata: ?*anyopaque) ?*Storage {
|
||||||
return @ptrCast(c.SDL_OpenStorage(@ptrCast(iface), userdata));
|
return @ptrCast(c.SDL_OpenStorage(@ptrCast(iface), userdata));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ pub const Surface = opaque {
|
||||||
return @bitCast(c.SDL_SurfaceHasAlternateImages(@ptrCast(surface)));
|
return @bitCast(c.SDL_SurfaceHasAlternateImages(@ptrCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceImages(surface: *Surface, count: *c_int) [*c][*c]Surface {
|
pub inline fn getSurfaceImages(surface: *Surface, count: *c_int) [*c]?*Surface {
|
||||||
return c.SDL_GetSurfaceImages(@ptrCast(surface), @ptrCast(count));
|
return c.SDL_GetSurfaceImages(@ptrCast(surface), @ptrCast(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,7 +222,7 @@ pub const Surface = opaque {
|
||||||
return @bitCast(c.SDL_GetSurfaceBlendMode(@ptrCast(surface), @ptrCast(blendMode)));
|
return @bitCast(c.SDL_GetSurfaceBlendMode(@ptrCast(surface), @ptrCast(blendMode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceClipRect(surface: *Surface, rect: *const Rect) bool {
|
pub inline fn setSurfaceClipRect(surface: *Surface, rect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_SetSurfaceClipRect(@ptrCast(surface), @ptrCast(rect)));
|
return @bitCast(c.SDL_SetSurfaceClipRect(@ptrCast(surface), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,43 +262,43 @@ pub const Surface = opaque {
|
||||||
return @bitCast(c.SDL_ClearSurface(@ptrCast(surface), r, g, b, a));
|
return @bitCast(c.SDL_ClearSurface(@ptrCast(surface), r, g, b, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn fillSurfaceRect(surface: *Surface, rect: *const Rect, color: u32) bool {
|
pub inline fn fillSurfaceRect(surface: *Surface, rect: ?*const Rect, color: u32) bool {
|
||||||
return @bitCast(c.SDL_FillSurfaceRect(@ptrCast(surface), @ptrCast(rect), color));
|
return @bitCast(c.SDL_FillSurfaceRect(@ptrCast(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 @bitCast(c.SDL_FillSurfaceRects(@ptrCast(surface), @ptrCast(rects), count, color));
|
return @bitCast(c.SDL_FillSurfaceRects(@ptrCast(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 @bitCast(c.SDL_BlitSurface(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurface(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(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 @bitCast(c.SDL_BlitSurfaceUnchecked(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurfaceUnchecked(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(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 @bitCast(c.SDL_BlitSurfaceScaled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect), @intFromEnum(scaleMode)));
|
return @bitCast(c.SDL_BlitSurfaceScaled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(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 @bitCast(c.SDL_BlitSurfaceUncheckedScaled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect), @intFromEnum(scaleMode)));
|
return @bitCast(c.SDL_BlitSurfaceUncheckedScaled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(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 @bitCast(c.SDL_StretchSurface(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect), @intFromEnum(scaleMode)));
|
return @bitCast(c.SDL_StretchSurface(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(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 @bitCast(c.SDL_BlitSurfaceTiled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurfaceTiled(@ptrCast(surface), @ptrCast(srcrect), @ptrCast(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 @bitCast(c.SDL_BlitSurfaceTiledWithScale(@ptrCast(surface), @ptrCast(srcrect), scale, @intFromEnum(scaleMode), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurfaceTiledWithScale(@ptrCast(surface), @ptrCast(srcrect), scale, @intFromEnum(scaleMode), @ptrCast(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 @bitCast(c.SDL_BlitSurface9Grid(@ptrCast(surface), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @intFromEnum(scaleMode), @ptrCast(dst), @ptrCast(dstrect)));
|
return @bitCast(c.SDL_BlitSurface9Grid(@ptrCast(surface), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @intFromEnum(scaleMode), @ptrCast(dst), @ptrCast(dstrect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ pub inline fn timeToDateTime(ticks: Time, dt: ?*DateTime, localTime: bool) bool
|
||||||
return @bitCast(c.SDL_TimeToDateTime(ticks, @ptrCast(dt), @bitCast(localTime)));
|
return @bitCast(c.SDL_TimeToDateTime(ticks, @ptrCast(dt), @bitCast(localTime)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn dateTimeToTime(dt: *const DateTime, ticks: ?*Time) bool {
|
pub inline fn dateTimeToTime(dt: ?*const DateTime, ticks: ?*Time) bool {
|
||||||
return @bitCast(c.SDL_DateTimeToTime(@ptrCast(dt), @ptrCast(ticks)));
|
return @bitCast(c.SDL_DateTimeToTime(@ptrCast(dt), @ptrCast(ticks)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,6 @@ pub inline fn getTouchDeviceType(touchID: TouchID) TouchDeviceType {
|
||||||
return @intFromEnum(c.SDL_GetTouchDeviceType(touchID));
|
return @intFromEnum(c.SDL_GetTouchDeviceType(touchID));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTouchFingers(touchID: TouchID, count: *c_int) [*c][*c]Finger {
|
pub inline fn getTouchFingers(touchID: TouchID, count: *c_int) [*c]?*Finger {
|
||||||
return c.SDL_GetTouchFingers(touchID, @ptrCast(count));
|
return c.SDL_GetTouchFingers(touchID, @ptrCast(count));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,11 @@ pub const Window = opaque {
|
||||||
return c.SDL_GetWindowDisplayScale(@ptrCast(window));
|
return c.SDL_GetWindowDisplayScale(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowFullscreenMode(window: *Window, mode: *const DisplayMode) bool {
|
pub inline fn setWindowFullscreenMode(window: *Window, mode: ?*const DisplayMode) bool {
|
||||||
return @bitCast(c.SDL_SetWindowFullscreenMode(@ptrCast(window), @ptrCast(mode)));
|
return @bitCast(c.SDL_SetWindowFullscreenMode(@ptrCast(window), @ptrCast(mode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFullscreenMode(window: *Window) *const DisplayMode {
|
pub inline fn getWindowFullscreenMode(window: *Window) ?*const DisplayMode {
|
||||||
return @ptrCast(c.SDL_GetWindowFullscreenMode(@ptrCast(window)));
|
return @ptrCast(c.SDL_GetWindowFullscreenMode(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,7 +245,7 @@ pub const Window = opaque {
|
||||||
return @bitCast(c.SDL_UpdateWindowSurface(@ptrCast(window)));
|
return @bitCast(c.SDL_UpdateWindowSurface(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateWindowSurfaceRects(window: *Window, rects: *const Rect, numrects: c_int) bool {
|
pub inline fn updateWindowSurfaceRects(window: *Window, rects: ?*const Rect, numrects: c_int) bool {
|
||||||
return @bitCast(c.SDL_UpdateWindowSurfaceRects(@ptrCast(window), @ptrCast(rects), numrects));
|
return @bitCast(c.SDL_UpdateWindowSurfaceRects(@ptrCast(window), @ptrCast(rects), numrects));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,11 +269,11 @@ pub const Window = opaque {
|
||||||
return @bitCast(c.SDL_GetWindowMouseGrab(@ptrCast(window)));
|
return @bitCast(c.SDL_GetWindowMouseGrab(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowMouseRect(window: *Window, rect: *const Rect) bool {
|
pub inline fn setWindowMouseRect(window: *Window, rect: ?*const Rect) bool {
|
||||||
return @bitCast(c.SDL_SetWindowMouseRect(@ptrCast(window), @ptrCast(rect)));
|
return @bitCast(c.SDL_SetWindowMouseRect(@ptrCast(window), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowMouseRect(window: *Window) *const Rect {
|
pub inline fn getWindowMouseRect(window: *Window) ?*const Rect {
|
||||||
return @ptrCast(c.SDL_GetWindowMouseRect(@ptrCast(window)));
|
return @ptrCast(c.SDL_GetWindowMouseRect(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -505,7 +505,7 @@ pub inline fn getDisplayContentScale(displayID: DisplayID) f32 {
|
||||||
return c.SDL_GetDisplayContentScale(displayID);
|
return c.SDL_GetDisplayContentScale(displayID);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getFullscreenDisplayModes(displayID: DisplayID, count: *c_int) [*c][*c]DisplayMode {
|
pub inline fn getFullscreenDisplayModes(displayID: DisplayID, count: *c_int) [*c]?*DisplayMode {
|
||||||
return @intFromEnum(c.SDL_GetFullscreenDisplayModes(displayID, @ptrCast(count)));
|
return @intFromEnum(c.SDL_GetFullscreenDisplayModes(displayID, @ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -513,23 +513,23 @@ pub inline fn getClosestFullscreenDisplayMode(displayID: DisplayID, w: c_int, h:
|
||||||
return @bitCast(c.SDL_GetClosestFullscreenDisplayMode(displayID, w, h, refresh_rate, @bitCast(include_high_density_modes), @ptrCast(closest)));
|
return @bitCast(c.SDL_GetClosestFullscreenDisplayMode(displayID, w, h, refresh_rate, @bitCast(include_high_density_modes), @ptrCast(closest)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDesktopDisplayMode(displayID: DisplayID) *const DisplayMode {
|
pub inline fn getDesktopDisplayMode(displayID: DisplayID) ?*const DisplayMode {
|
||||||
return @ptrCast(c.SDL_GetDesktopDisplayMode(displayID));
|
return @ptrCast(c.SDL_GetDesktopDisplayMode(displayID));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCurrentDisplayMode(displayID: DisplayID) *const DisplayMode {
|
pub inline fn getCurrentDisplayMode(displayID: DisplayID) ?*const DisplayMode {
|
||||||
return @ptrCast(c.SDL_GetCurrentDisplayMode(displayID));
|
return @ptrCast(c.SDL_GetCurrentDisplayMode(displayID));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayForPoint(point: *const Point) DisplayID {
|
pub inline fn getDisplayForPoint(point: ?*const Point) DisplayID {
|
||||||
return c.SDL_GetDisplayForPoint(@ptrCast(point));
|
return c.SDL_GetDisplayForPoint(@ptrCast(point));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayForRect(rect: *const Rect) DisplayID {
|
pub inline fn getDisplayForRect(rect: ?*const Rect) DisplayID {
|
||||||
return c.SDL_GetDisplayForRect(@ptrCast(rect));
|
return c.SDL_GetDisplayForRect(@ptrCast(rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindows(count: *c_int) [*c][*c]Window {
|
pub inline fn getWindows(count: *c_int) [*c]?*Window {
|
||||||
return c.SDL_GetWindows(@ptrCast(count));
|
return c.SDL_GetWindows(@ptrCast(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const sdl = @import("sdl3");
|
||||||
|
|
||||||
|
pub fn main() !void {
|
||||||
|
// Initialize SDL with video subsystem
|
||||||
|
if (!sdl.init_fn(sdl.InitFlags{ .initVideo = true })) {
|
||||||
|
std.debug.print("SDL_Init failed: {s}\n", .{sdl.error_.getError()});
|
||||||
|
return error.SDLInitFailed;
|
||||||
|
}
|
||||||
|
defer sdl.quit();
|
||||||
|
|
||||||
|
// Create window
|
||||||
|
const window = sdl.createWindow(
|
||||||
|
"SDL3 GPU Sample - Clear Screen",
|
||||||
|
800,
|
||||||
|
600,
|
||||||
|
sdl.WindowFlags{},
|
||||||
|
) orelse {
|
||||||
|
std.debug.print("SDL_CreateWindow failed: {s}\n", .{sdl.error_.getError()});
|
||||||
|
return error.WindowCreationFailed;
|
||||||
|
};
|
||||||
|
defer sdl.video.Window.destroyWindow(window);
|
||||||
|
|
||||||
|
// Create GPU device with all shader formats enabled
|
||||||
|
const gpu_device = sdl.gpu.createGPUDevice(sdl.gpu.GPUShaderFormat{
|
||||||
|
.shaderformatSpirv = true, // Vulkan
|
||||||
|
.shaderformatDxil = true, // D3D12
|
||||||
|
.shaderformatMetallib = true, // Metal
|
||||||
|
}, false, null) orelse {
|
||||||
|
std.debug.print("SDL_CreateGPUDevice failed: {s}\n", .{sdl.error_.getError()});
|
||||||
|
return error.GPUDeviceCreationFailed;
|
||||||
|
};
|
||||||
|
defer gpu_device.destroyGPUDevice();
|
||||||
|
|
||||||
|
// Claim window for GPU device
|
||||||
|
if (!gpu_device.claimWindowForGPUDevice(@ptrCast(window))) {
|
||||||
|
std.debug.print("SDL_ClaimWindowForGPUDevice failed: {s}\n", .{sdl.error_.getError()});
|
||||||
|
return error.ClaimWindowFailed;
|
||||||
|
}
|
||||||
|
|
||||||
|
std.debug.print("GPU Device initialized successfully!\n", .{});
|
||||||
|
std.debug.print("Driver: {s}\n", .{gpu_device.getGPUDeviceDriver()});
|
||||||
|
|
||||||
|
// Main loop
|
||||||
|
var running = true;
|
||||||
|
while (running) {
|
||||||
|
var event: sdl.events.Event = undefined;
|
||||||
|
while (sdl.events.pollEvent(&event)) {
|
||||||
|
switch (event._type) {
|
||||||
|
@intFromEnum(sdl.events.EventType.eventQuit) => {
|
||||||
|
running = false;
|
||||||
|
},
|
||||||
|
@intFromEnum(sdl.events.EventType.eventKeyDown) => {
|
||||||
|
if (event.key.key == sdl.keycode.c.SDLK_ESCAPE) {
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acquire command buffer
|
||||||
|
const cmd_buf = gpu_device.acquireGPUCommandBuffer() orelse {
|
||||||
|
std.debug.print("SDL_AcquireGPUCommandBuffer failed: {s}\n", .{sdl.error_.getError()});
|
||||||
|
return error.AcquireCommandBufferFailed;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Acquire swapchain texture
|
||||||
|
var swapchain_texture: ?*sdl.gpu.GPUTexture = null;
|
||||||
|
var width: u32 = 0;
|
||||||
|
var height: u32 = 0;
|
||||||
|
if (!cmd_buf.waitAndAcquireGPUSwapchainTexture(@ptrCast(window), &swapchain_texture, &width, &height)) {
|
||||||
|
std.debug.print("SDL_WaitAndAcquireGPUSwapchainTexture failed: {s}\n", .{sdl.error_.getError()});
|
||||||
|
return error.AcquireSwapchainFailed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (swapchain_texture) |texture| {
|
||||||
|
// Set up color target with yellowish clear color
|
||||||
|
const color_target = sdl.gpu.GPUColorTargetInfo{
|
||||||
|
.texture = texture,
|
||||||
|
.mip_level = 0,
|
||||||
|
.layer_or_depth_plane = 0,
|
||||||
|
.clear_color = sdl.gpu.FColor{
|
||||||
|
.r = 0.9,
|
||||||
|
.g = 0.8,
|
||||||
|
.b = 0.3,
|
||||||
|
.a = 1.0,
|
||||||
|
},
|
||||||
|
.load_op = sdl.gpu.GPULoadOp.loadopClear,
|
||||||
|
.store_op = sdl.gpu.GPUStoreOp.storeopStore,
|
||||||
|
.resolve_texture = null,
|
||||||
|
.resolve_mip_level = 0,
|
||||||
|
.resolve_layer = 0,
|
||||||
|
.cycle = false,
|
||||||
|
.cycle_resolve_texture = false,
|
||||||
|
.padding1 = 0,
|
||||||
|
.padding2 = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Begin render pass
|
||||||
|
const render_pass = cmd_buf.beginGPURenderPass(&color_target, 1, null) orelse {
|
||||||
|
std.debug.print("SDL_BeginGPURenderPass failed: {s}\n", .{sdl.error_.getError()});
|
||||||
|
return error.BeginRenderPassFailed;
|
||||||
|
};
|
||||||
|
|
||||||
|
// End render pass (no drawing, just clear)
|
||||||
|
render_pass.endGPURenderPass();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Submit command buffer
|
||||||
|
_ = cmd_buf.submitGPUCommandBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue