fixed return types and works with sdl3 example.
This commit is contained in:
parent
16bea32e5a
commit
51176cba15
117
AGENTS.md
117
AGENTS.md
|
|
@ -24,6 +24,44 @@ The codebase consists of several modules:
|
||||||
- `types.zig` - Type mapping and conversions
|
- `types.zig` - Type mapping and conversions
|
||||||
- `naming.zig` - Naming conventions
|
- `naming.zig` - Naming conventions
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Building and Running
|
||||||
|
|
||||||
|
**Generate all headers:**
|
||||||
|
```bash
|
||||||
|
zig build generate
|
||||||
|
```
|
||||||
|
This processes all SDL3 headers and generates corresponding Zig files in the `api/` directory.
|
||||||
|
|
||||||
|
**Generate a single header:**
|
||||||
|
```bash
|
||||||
|
zig build run -- <path-to-header> --output=<output-path>
|
||||||
|
```
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```bash
|
||||||
|
zig build run -- sdl3\include\SDL3\SDL_gpu.h --output=api\gpu.zig
|
||||||
|
```
|
||||||
|
|
||||||
|
The parser converts C headers to Zig files:
|
||||||
|
- `SDL_gpu.h` → `gpu.zig`
|
||||||
|
- `SDL_video.h` → `video.zig`
|
||||||
|
- `SDL_events.h` → `events.zig`
|
||||||
|
|
||||||
|
**Additional options:**
|
||||||
|
- `--mocks=<path>` - Generate C mock implementations
|
||||||
|
- `--generate-json=<path>` - Generate JSON representation
|
||||||
|
- `--timestamp=<timestamp>` - Set custom timestamp
|
||||||
|
- `--basedir=<directory>` - Set base directory for dependency resolution
|
||||||
|
|
||||||
|
### Output Directories
|
||||||
|
|
||||||
|
- `api/` - Generated Zig API files (final output)
|
||||||
|
- `tmp/` - Temporary files during generation (before validation)
|
||||||
|
- `debug/` - Debug output when generation fails (with `_fmterror.zig` suffix)
|
||||||
|
- `archive/` - Archived previous debug outputs
|
||||||
|
|
||||||
## Developing
|
## Developing
|
||||||
|
|
||||||
### Build System Patterns
|
### Build System Patterns
|
||||||
|
|
@ -71,6 +109,29 @@ try io.emitError(allocator, "Failed to parse struct field: {s}", .{field_name});
|
||||||
std.debug.print("Error: Failed to parse...\n", .{});
|
std.debug.print("Error: Failed to parse...\n", .{});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Type Casting in Generated Code
|
||||||
|
|
||||||
|
The code generator automatically adds appropriate casts when calling C functions:
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- Opaque pointers (`*Window`, `?*GPUDevice`) → `@ptrCast`
|
||||||
|
- Enums → `@intFromEnum`
|
||||||
|
- Flags (packed structs) → `@bitCast`
|
||||||
|
- Booleans → `@bitCast`
|
||||||
|
|
||||||
|
**Return values:**
|
||||||
|
- Opaque pointers (`?*Window`) → `@ptrCast`
|
||||||
|
- Booleans → `@bitCast`
|
||||||
|
- Flags (packed structs) → `@bitCast`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```zig
|
||||||
|
pub inline fn createWindow(title: [*c]const u8, w: c_int, h: c_int, flags: WindowFlags) ?*Window {
|
||||||
|
return @ptrCast(c.SDL_CreateWindow(title, w, h, @bitCast(flags)));
|
||||||
|
// ^^^^^^^^ return cast ^^^^^ param cast
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Validation Process
|
### Validation Process
|
||||||
After generating Zig code:
|
After generating Zig code:
|
||||||
1. Output written to `tmp/` directory
|
1. Output written to `tmp/` directory
|
||||||
|
|
@ -78,13 +139,69 @@ After generating Zig code:
|
||||||
3. If passes: `zig fmt` runs, then copied to final destination
|
3. If passes: `zig fmt` runs, then copied to final destination
|
||||||
4. If fails: debug output written to `debug/` with `_fmterror.zig` suffix
|
4. If fails: debug output written to `debug/` with `_fmterror.zig` suffix
|
||||||
|
|
||||||
|
**Testing all outputs:**
|
||||||
|
Use `zig build generate` to regenerate all SDL3 headers and verify no regressions.
|
||||||
|
|
||||||
### Memory Management
|
### Memory Management
|
||||||
- Two cleanup functions exist with identical logic:
|
- Two cleanup functions exist with identical logic:
|
||||||
- `freeDecls()` - frees a slice of declarations
|
- `freeDecls()` - frees a slice of declarations
|
||||||
- `freeDeclDeep()` - frees a single declaration
|
- `freeDeclDeep()` - frees a single declaration
|
||||||
- Both free all nested allocations (names, types, doc comments, params/fields/values/flags)
|
- Both free all nested allocations (names, types, doc comments, params/fields/values/flags)
|
||||||
|
|
||||||
|
### Zig 0.15 Specifics
|
||||||
|
**IMPORTANT:** In Zig 0.15, `std.ArrayList` is an alias to `std.ArrayListUnmanaged`. This means:
|
||||||
|
- ArrayList methods require an explicit allocator parameter
|
||||||
|
- Use `list.append(allocator, item)` instead of `list.append(item)`
|
||||||
|
- Use `list.toOwnedSlice(allocator)` instead of `list.toOwnedSlice()`
|
||||||
|
- Use `list.deinit(allocator)` instead of `list.deinit()`
|
||||||
|
- Initialize with `std.ArrayList(T){}` (empty init)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```zig
|
||||||
|
var list = std.ArrayList(MyType){};
|
||||||
|
errdefer list.deinit(allocator);
|
||||||
|
try list.append(allocator, item);
|
||||||
|
const slice = try list.toOwnedSlice(allocator);
|
||||||
|
```
|
||||||
|
|
||||||
### Main APIs (Priority)
|
### Main APIs (Priority)
|
||||||
Focus areas: gpu, video, gamepad, joystick, input, event
|
Focus areas: gpu, video, gamepad, joystick, input, event
|
||||||
|
|
||||||
Anything beyond these is not actively maintained.
|
Anything beyond these is not actively maintained.
|
||||||
|
|
||||||
|
## Code Generation Features
|
||||||
|
|
||||||
|
### Enum-to-Flags Conversion
|
||||||
|
The parser automatically detects enums that contain bitwise OR operations and converts them to packed structs with bool flags.
|
||||||
|
|
||||||
|
**Example:** SDL_FlipMode in SDL_surface.h
|
||||||
|
```c
|
||||||
|
// C enum with bitwise OR
|
||||||
|
typedef enum SDL_FlipMode {
|
||||||
|
SDL_FLIP_NONE, // 0
|
||||||
|
SDL_FLIP_HORIZONTAL, // 1
|
||||||
|
SDL_FLIP_VERTICAL, // 2
|
||||||
|
SDL_FLIP_HORIZONTAL_AND_VERTICAL = (SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL) // 3
|
||||||
|
} SDL_FlipMode;
|
||||||
|
```
|
||||||
|
|
||||||
|
Converts to:
|
||||||
|
```zig
|
||||||
|
// Zig packed struct with bool flags
|
||||||
|
pub const FlipMode = packed struct(u32) {
|
||||||
|
flipHorizontal: bool = false,
|
||||||
|
flipVertical: bool = false,
|
||||||
|
pad0: u29 = 0,
|
||||||
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = FlipMode{};
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
- `FlipMode.None` - no flip (matches C's SDL_FLIP_NONE)
|
||||||
|
- `FlipMode{ .flipHorizontal = true }` - horizontal flip
|
||||||
|
- `FlipMode{ .flipVertical = true }` - vertical flip
|
||||||
|
- `FlipMode{ .flipHorizontal = true, .flipVertical = true }` - both (equivalent to SDL_FLIP_HORIZONTAL_AND_VERTICAL)
|
||||||
|
|
||||||
|
This approach eliminates the need for explicit combined values and provides a type-safe way to combine flags.
|
||||||
|
|
|
||||||
125
api/audio.zig
125
api/audio.zig
|
|
@ -1,24 +1,25 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub const PropertiesID = u32;
|
|
||||||
|
|
||||||
pub const IOStream = opaque {
|
pub const IOStream = opaque {
|
||||||
pub inline fn loadWAV_IO(iostream: *IOStream, closeio: bool, spec: ?*AudioSpec, audio_buf: [*c][*c]u8, audio_len: *u32) bool {
|
pub inline fn loadWAV_IO(iostream: *IOStream, closeio: bool, spec: ?*AudioSpec, audio_buf: [*c][*c]u8, audio_len: *u32) bool {
|
||||||
return c.SDL_LoadWAV_IO(iostream, closeio, spec, audio_buf, @ptrCast(audio_len));
|
return @bitCast(c.SDL_LoadWAV_IO(@ptrCast(iostream), @bitCast(closeio), @ptrCast(spec), audio_buf, @ptrCast(audio_len)));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const PropertiesID = u32;
|
||||||
|
|
||||||
pub const AudioFormat = enum(c_int) {
|
pub const AudioFormat = enum(c_int) {
|
||||||
audioUnknown, //Unspecified audio format
|
audioUnknown = 0x0000, //Unspecified audio format
|
||||||
audioU8, //Unsigned 8-bit samples
|
audioU8 = 0x0008, //Unsigned 8-bit samples
|
||||||
audioS8, //Signed 8-bit samples
|
audioS8 = 0x8008, //Signed 8-bit samples
|
||||||
audioS16le, //Signed 16-bit samples
|
audioS16le = 0x8010, //Signed 16-bit samples
|
||||||
audioS16be, //As above, but big-endian byte order
|
audioS16be = 0x9010, //As above, but big-endian byte order
|
||||||
audioS32le, //32-bit integer samples
|
audioS32le = 0x8020, //32-bit integer samples
|
||||||
audioS32be, //As above, but big-endian byte order
|
audioS32be = 0x9020, //As above, but big-endian byte order
|
||||||
audioF32le, //32-bit floating point samples
|
audioF32le = 0x8120, //32-bit floating point samples
|
||||||
audioF32be, //As above, but big-endian byte order
|
audioF32be = 0x9120, //As above, but big-endian byte order
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const AudioDeviceID = u32;
|
pub const AudioDeviceID = u32;
|
||||||
|
|
@ -31,112 +32,121 @@ pub const AudioSpec = extern struct {
|
||||||
|
|
||||||
pub const AudioStream = opaque {
|
pub const AudioStream = opaque {
|
||||||
pub inline fn unbindAudioStream(audiostream: *AudioStream) void {
|
pub inline fn unbindAudioStream(audiostream: *AudioStream) void {
|
||||||
return c.SDL_UnbindAudioStream(audiostream);
|
return c.SDL_UnbindAudioStream(@ptrCast(audiostream));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamDevice(audiostream: *AudioStream) AudioDeviceID {
|
pub inline fn getAudioStreamDevice(audiostream: *AudioStream) AudioDeviceID {
|
||||||
return c.SDL_GetAudioStreamDevice(audiostream);
|
return c.SDL_GetAudioStreamDevice(@ptrCast(audiostream));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamProperties(audiostream: *AudioStream) PropertiesID {
|
pub inline fn getAudioStreamProperties(audiostream: *AudioStream) PropertiesID {
|
||||||
return c.SDL_GetAudioStreamProperties(audiostream);
|
return c.SDL_GetAudioStreamProperties(@ptrCast(audiostream));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamFormat(audiostream: *AudioStream, src_spec: ?*AudioSpec, dst_spec: ?*AudioSpec) bool {
|
pub inline fn getAudioStreamFormat(audiostream: *AudioStream, src_spec: ?*AudioSpec, dst_spec: ?*AudioSpec) bool {
|
||||||
return c.SDL_GetAudioStreamFormat(audiostream, src_spec, 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 c.SDL_SetAudioStreamFormat(audiostream, @ptrCast(src_spec), @ptrCast(dst_spec));
|
return @bitCast(c.SDL_SetAudioStreamFormat(@ptrCast(audiostream), @ptrCast(src_spec), @ptrCast(dst_spec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamFrequencyRatio(audiostream: *AudioStream) f32 {
|
pub inline fn getAudioStreamFrequencyRatio(audiostream: *AudioStream) f32 {
|
||||||
return c.SDL_GetAudioStreamFrequencyRatio(audiostream);
|
return c.SDL_GetAudioStreamFrequencyRatio(@ptrCast(audiostream));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamFrequencyRatio(audiostream: *AudioStream, ratio: f32) bool {
|
pub inline fn setAudioStreamFrequencyRatio(audiostream: *AudioStream, ratio: f32) bool {
|
||||||
return c.SDL_SetAudioStreamFrequencyRatio(audiostream, ratio);
|
return @bitCast(c.SDL_SetAudioStreamFrequencyRatio(@ptrCast(audiostream), ratio));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamGain(audiostream: *AudioStream) f32 {
|
pub inline fn getAudioStreamGain(audiostream: *AudioStream) f32 {
|
||||||
return c.SDL_GetAudioStreamGain(audiostream);
|
return c.SDL_GetAudioStreamGain(@ptrCast(audiostream));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamGain(audiostream: *AudioStream, gain: f32) bool {
|
pub inline fn setAudioStreamGain(audiostream: *AudioStream, gain: f32) bool {
|
||||||
return c.SDL_SetAudioStreamGain(audiostream, gain);
|
return @bitCast(c.SDL_SetAudioStreamGain(@ptrCast(audiostream), gain));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamInputChannelMap(audiostream: *AudioStream, count: *c_int) *c_int {
|
pub inline fn getAudioStreamInputChannelMap(audiostream: *AudioStream, count: *c_int) *c_int {
|
||||||
return @ptrCast(c.SDL_GetAudioStreamInputChannelMap(audiostream, @ptrCast(count)));
|
return @ptrCast(c.SDL_GetAudioStreamInputChannelMap(@ptrCast(audiostream), @ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamOutputChannelMap(audiostream: *AudioStream, count: *c_int) *c_int {
|
pub inline fn getAudioStreamOutputChannelMap(audiostream: *AudioStream, count: *c_int) *c_int {
|
||||||
return @ptrCast(c.SDL_GetAudioStreamOutputChannelMap(audiostream, @ptrCast(count)));
|
return @ptrCast(c.SDL_GetAudioStreamOutputChannelMap(@ptrCast(audiostream), @ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamInputChannelMap(audiostream: *AudioStream, chmap: [*c]const c_int, count: c_int) bool {
|
pub inline fn setAudioStreamInputChannelMap(audiostream: *AudioStream, chmap: [*c]const c_int, count: c_int) bool {
|
||||||
return c.SDL_SetAudioStreamInputChannelMap(audiostream, chmap, count);
|
return @bitCast(c.SDL_SetAudioStreamInputChannelMap(@ptrCast(audiostream), chmap, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamOutputChannelMap(audiostream: *AudioStream, chmap: [*c]const c_int, count: c_int) bool {
|
pub inline fn setAudioStreamOutputChannelMap(audiostream: *AudioStream, chmap: [*c]const c_int, count: c_int) bool {
|
||||||
return c.SDL_SetAudioStreamOutputChannelMap(audiostream, chmap, count);
|
return @bitCast(c.SDL_SetAudioStreamOutputChannelMap(@ptrCast(audiostream), chmap, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn putAudioStreamData(audiostream: *AudioStream, buf: ?*const anyopaque, len: c_int) bool {
|
pub inline fn putAudioStreamData(audiostream: *AudioStream, buf: ?*const anyopaque, len: c_int) bool {
|
||||||
return c.SDL_PutAudioStreamData(audiostream, buf, len);
|
return @bitCast(c.SDL_PutAudioStreamData(@ptrCast(audiostream), buf, len));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn putAudioStreamDataNoCopy(audiostream: *AudioStream, buf: ?*const anyopaque, len: c_int, callback: AudioStreamDataCompleteCallback, userdata: ?*anyopaque) bool {
|
||||||
|
return @bitCast(c.SDL_PutAudioStreamDataNoCopy(@ptrCast(audiostream), buf, len, callback, userdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn putAudioStreamPlanarData(audiostream: *AudioStream, channel_buffers: [*c]const void * const, 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(audiostream, buf, len);
|
return c.SDL_GetAudioStreamData(@ptrCast(audiostream), buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamAvailable(audiostream: *AudioStream) c_int {
|
pub inline fn getAudioStreamAvailable(audiostream: *AudioStream) c_int {
|
||||||
return c.SDL_GetAudioStreamAvailable(audiostream);
|
return c.SDL_GetAudioStreamAvailable(@ptrCast(audiostream));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioStreamQueued(audiostream: *AudioStream) c_int {
|
pub inline fn getAudioStreamQueued(audiostream: *AudioStream) c_int {
|
||||||
return c.SDL_GetAudioStreamQueued(audiostream);
|
return c.SDL_GetAudioStreamQueued(@ptrCast(audiostream));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn flushAudioStream(audiostream: *AudioStream) bool {
|
pub inline fn flushAudioStream(audiostream: *AudioStream) bool {
|
||||||
return c.SDL_FlushAudioStream(audiostream);
|
return @bitCast(c.SDL_FlushAudioStream(@ptrCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn clearAudioStream(audiostream: *AudioStream) bool {
|
pub inline fn clearAudioStream(audiostream: *AudioStream) bool {
|
||||||
return c.SDL_ClearAudioStream(audiostream);
|
return @bitCast(c.SDL_ClearAudioStream(@ptrCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pauseAudioStreamDevice(audiostream: *AudioStream) bool {
|
pub inline fn pauseAudioStreamDevice(audiostream: *AudioStream) bool {
|
||||||
return c.SDL_PauseAudioStreamDevice(audiostream);
|
return @bitCast(c.SDL_PauseAudioStreamDevice(@ptrCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn resumeAudioStreamDevice(audiostream: *AudioStream) bool {
|
pub inline fn resumeAudioStreamDevice(audiostream: *AudioStream) bool {
|
||||||
return c.SDL_ResumeAudioStreamDevice(audiostream);
|
return @bitCast(c.SDL_ResumeAudioStreamDevice(@ptrCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn audioStreamDevicePaused(audiostream: *AudioStream) bool {
|
pub inline fn audioStreamDevicePaused(audiostream: *AudioStream) bool {
|
||||||
return c.SDL_AudioStreamDevicePaused(audiostream);
|
return @bitCast(c.SDL_AudioStreamDevicePaused(@ptrCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn lockAudioStream(audiostream: *AudioStream) bool {
|
pub inline fn lockAudioStream(audiostream: *AudioStream) bool {
|
||||||
return c.SDL_LockAudioStream(audiostream);
|
return @bitCast(c.SDL_LockAudioStream(@ptrCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unlockAudioStream(audiostream: *AudioStream) bool {
|
pub inline fn unlockAudioStream(audiostream: *AudioStream) bool {
|
||||||
return c.SDL_UnlockAudioStream(audiostream);
|
return @bitCast(c.SDL_UnlockAudioStream(@ptrCast(audiostream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamGetCallback(audiostream: *AudioStream, callback: AudioStreamCallback, userdata: ?*anyopaque) bool {
|
pub inline fn setAudioStreamGetCallback(audiostream: *AudioStream, callback: AudioStreamCallback, userdata: ?*anyopaque) bool {
|
||||||
return c.SDL_SetAudioStreamGetCallback(audiostream, callback, userdata);
|
return @bitCast(c.SDL_SetAudioStreamGetCallback(@ptrCast(audiostream), callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioStreamPutCallback(audiostream: *AudioStream, callback: AudioStreamCallback, userdata: ?*anyopaque) bool {
|
pub inline fn setAudioStreamPutCallback(audiostream: *AudioStream, callback: AudioStreamCallback, userdata: ?*anyopaque) bool {
|
||||||
return c.SDL_SetAudioStreamPutCallback(audiostream, callback, userdata);
|
return @bitCast(c.SDL_SetAudioStreamPutCallback(@ptrCast(audiostream), callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyAudioStream(audiostream: *AudioStream) void {
|
pub inline fn destroyAudioStream(audiostream: *AudioStream) void {
|
||||||
return c.SDL_DestroyAudioStream(audiostream);
|
return c.SDL_DestroyAudioStream(@ptrCast(audiostream));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getNumAudioDrivers() c_int {
|
pub inline fn getNumAudioDrivers() c_int {
|
||||||
|
|
@ -152,11 +162,11 @@ pub inline fn getCurrentAudioDriver() [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioPlaybackDevices(count: *c_int) ?*AudioDeviceID {
|
pub inline fn getAudioPlaybackDevices(count: *c_int) ?*AudioDeviceID {
|
||||||
return c.SDL_GetAudioPlaybackDevices(@ptrCast(count));
|
return @ptrCast(c.SDL_GetAudioPlaybackDevices(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioRecordingDevices(count: *c_int) ?*AudioDeviceID {
|
pub inline fn getAudioRecordingDevices(count: *c_int) ?*AudioDeviceID {
|
||||||
return c.SDL_GetAudioRecordingDevices(@ptrCast(count));
|
return @ptrCast(c.SDL_GetAudioRecordingDevices(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioDeviceName(devid: AudioDeviceID) [*c]const u8 {
|
pub inline fn getAudioDeviceName(devid: AudioDeviceID) [*c]const u8 {
|
||||||
|
|
@ -164,7 +174,7 @@ pub inline fn getAudioDeviceName(devid: AudioDeviceID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioDeviceFormat(devid: AudioDeviceID, spec: ?*AudioSpec, sample_frames: *c_int) bool {
|
pub inline fn getAudioDeviceFormat(devid: AudioDeviceID, spec: ?*AudioSpec, sample_frames: *c_int) bool {
|
||||||
return c.SDL_GetAudioDeviceFormat(devid, spec, @ptrCast(sample_frames));
|
return @bitCast(c.SDL_GetAudioDeviceFormat(devid, @ptrCast(spec), @ptrCast(sample_frames)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioDeviceChannelMap(devid: AudioDeviceID, count: *c_int) *c_int {
|
pub inline fn getAudioDeviceChannelMap(devid: AudioDeviceID, count: *c_int) *c_int {
|
||||||
|
|
@ -176,23 +186,23 @@ pub inline fn openAudioDevice(devid: AudioDeviceID, spec: *const AudioSpec) Audi
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isAudioDevicePhysical(devid: AudioDeviceID) bool {
|
pub inline fn isAudioDevicePhysical(devid: AudioDeviceID) bool {
|
||||||
return c.SDL_IsAudioDevicePhysical(devid);
|
return @bitCast(c.SDL_IsAudioDevicePhysical(devid));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isAudioDevicePlayback(devid: AudioDeviceID) bool {
|
pub inline fn isAudioDevicePlayback(devid: AudioDeviceID) bool {
|
||||||
return c.SDL_IsAudioDevicePlayback(devid);
|
return @bitCast(c.SDL_IsAudioDevicePlayback(devid));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pauseAudioDevice(devid: AudioDeviceID) bool {
|
pub inline fn pauseAudioDevice(devid: AudioDeviceID) bool {
|
||||||
return c.SDL_PauseAudioDevice(devid);
|
return @bitCast(c.SDL_PauseAudioDevice(devid));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn resumeAudioDevice(devid: AudioDeviceID) bool {
|
pub inline fn resumeAudioDevice(devid: AudioDeviceID) bool {
|
||||||
return c.SDL_ResumeAudioDevice(devid);
|
return @bitCast(c.SDL_ResumeAudioDevice(devid));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn audioDevicePaused(devid: AudioDeviceID) bool {
|
pub inline fn audioDevicePaused(devid: AudioDeviceID) bool {
|
||||||
return c.SDL_AudioDevicePaused(devid);
|
return @bitCast(c.SDL_AudioDevicePaused(devid));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioDeviceGain(devid: AudioDeviceID) f32 {
|
pub inline fn getAudioDeviceGain(devid: AudioDeviceID) f32 {
|
||||||
|
|
@ -200,7 +210,7 @@ pub inline fn getAudioDeviceGain(devid: AudioDeviceID) f32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAudioDeviceGain(devid: AudioDeviceID, gain: f32) bool {
|
pub inline fn setAudioDeviceGain(devid: AudioDeviceID, gain: f32) bool {
|
||||||
return c.SDL_SetAudioDeviceGain(devid, gain);
|
return @bitCast(c.SDL_SetAudioDeviceGain(devid, gain));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeAudioDevice(devid: AudioDeviceID) void {
|
pub inline fn closeAudioDevice(devid: AudioDeviceID) void {
|
||||||
|
|
@ -208,11 +218,11 @@ pub inline fn closeAudioDevice(devid: AudioDeviceID) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 c.SDL_BindAudioStreams(devid, streams, num_streams);
|
return @bitCast(c.SDL_BindAudioStreams(devid, streams, num_streams));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn bindAudioStream(devid: AudioDeviceID, stream: ?*AudioStream) bool {
|
pub inline fn bindAudioStream(devid: AudioDeviceID, stream: ?*AudioStream) bool {
|
||||||
return c.SDL_BindAudioStream(devid, 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 {
|
||||||
|
|
@ -220,31 +230,33 @@ pub inline fn unbindAudioStreams(streams: [*c]*const AudioStream, num_streams: c
|
||||||
}
|
}
|
||||||
|
|
||||||
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 c.SDL_CreateAudioStream(@ptrCast(src_spec), @ptrCast(dst_spec));
|
return @ptrCast(c.SDL_CreateAudioStream(@ptrCast(src_spec), @ptrCast(dst_spec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const AudioStreamDataCompleteCallback = c.SDL_AudioStreamDataCompleteCallback;
|
||||||
|
|
||||||
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 c.SDL_OpenAudioDeviceStream(devid, @ptrCast(spec), callback, userdata);
|
return @ptrCast(c.SDL_OpenAudioDeviceStream(devid, @ptrCast(spec), callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const AudioPostmixCallback = c.SDL_AudioPostmixCallback;
|
pub const AudioPostmixCallback = c.SDL_AudioPostmixCallback;
|
||||||
|
|
||||||
pub inline fn setAudioPostmixCallback(devid: AudioDeviceID, callback: AudioPostmixCallback, userdata: ?*anyopaque) bool {
|
pub inline fn setAudioPostmixCallback(devid: AudioDeviceID, callback: AudioPostmixCallback, userdata: ?*anyopaque) bool {
|
||||||
return c.SDL_SetAudioPostmixCallback(devid, callback, userdata);
|
return @bitCast(c.SDL_SetAudioPostmixCallback(devid, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadWAV(path: [*c]const u8, spec: ?*AudioSpec, audio_buf: [*c][*c]u8, audio_len: *u32) bool {
|
pub inline fn loadWAV(path: [*c]const u8, spec: ?*AudioSpec, audio_buf: [*c][*c]u8, audio_len: *u32) bool {
|
||||||
return c.SDL_LoadWAV(path, spec, audio_buf, @ptrCast(audio_len));
|
return @bitCast(c.SDL_LoadWAV(path, @ptrCast(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);
|
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 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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAudioFormatName(format: AudioFormat) [*c]const u8 {
|
pub inline fn getAudioFormatName(format: AudioFormat) [*c]const u8 {
|
||||||
|
|
@ -254,3 +266,4 @@ pub inline fn getAudioFormatName(format: AudioFormat) [*c]const u8 {
|
||||||
pub inline fn getSilenceValueForFormat(format: AudioFormat) c_int {
|
pub inline fn getSilenceValueForFormat(format: AudioFormat) c_int {
|
||||||
return c.SDL_GetSilenceValueForFormat(@bitCast(format));
|
return c.SDL_GetSilenceValueForFormat(@bitCast(format));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,24 @@ pub const c = @import("c.zig").c;
|
||||||
pub const BlendMode = u32;
|
pub const BlendMode = u32;
|
||||||
|
|
||||||
pub const BlendOperation = enum(c_int) {
|
pub const BlendOperation = enum(c_int) {
|
||||||
blendoperationAdd, //dst + src: supported by all renderers
|
blendoperationAdd = 0x1, //dst + src: supported by all renderers
|
||||||
blendoperationSubtract, //src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
blendoperationSubtract = 0x2, //src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
||||||
blendoperationRevSubtract, //dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
blendoperationRevSubtract = 0x3, //dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
||||||
blendoperationMinimum, //min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
blendoperationMinimum = 0x4, //min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan
|
||||||
blendoperationMaximum,
|
blendoperationMaximum = 0x5,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const BlendFactor = enum(c_int) {
|
pub const BlendFactor = enum(c_int) {
|
||||||
blendfactorZero, //0, 0, 0, 0
|
blendfactorZero = 0x1, //0, 0, 0, 0
|
||||||
blendfactorOne, //1, 1, 1, 1
|
blendfactorOne = 0x2, //1, 1, 1, 1
|
||||||
blendfactorSrcColor, //srcR, srcG, srcB, srcA
|
blendfactorSrcColor = 0x3, //srcR, srcG, srcB, srcA
|
||||||
blendfactorOneMinusSrcColor, //1-srcR, 1-srcG, 1-srcB, 1-srcA
|
blendfactorOneMinusSrcColor = 0x4, //1-srcR, 1-srcG, 1-srcB, 1-srcA
|
||||||
blendfactorSrcAlpha, //srcA, srcA, srcA, srcA
|
blendfactorSrcAlpha = 0x5, //srcA, srcA, srcA, srcA
|
||||||
blendfactorOneMinusSrcAlpha, //1-srcA, 1-srcA, 1-srcA, 1-srcA
|
blendfactorOneMinusSrcAlpha = 0x6, //1-srcA, 1-srcA, 1-srcA, 1-srcA
|
||||||
blendfactorDstColor, //dstR, dstG, dstB, dstA
|
blendfactorDstColor = 0x7, //dstR, dstG, dstB, dstA
|
||||||
blendfactorOneMinusDstColor, //1-dstR, 1-dstG, 1-dstB, 1-dstA
|
blendfactorOneMinusDstColor = 0x8, //1-dstR, 1-dstG, 1-dstB, 1-dstA
|
||||||
blendfactorDstAlpha, //dstA, dstA, dstA, dstA
|
blendfactorDstAlpha = 0x9, //dstA, dstA, dstA, dstA
|
||||||
blendfactorOneMinusDstAlpha,
|
blendfactorOneMinusDstAlpha = 0xA,
|
||||||
};
|
};
|
||||||
|
|
||||||
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 {
|
||||||
|
|
|
||||||
|
|
@ -2,47 +2,48 @@ const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub const PixelFormat = enum(c_int) {
|
pub const PixelFormat = enum(c_int) {
|
||||||
pixelformatYv12, //Planar mode: Y + V + U (3 planes)
|
pixelformatYv12 = 0x32315659, //Planar mode: Y + V + U (3 planes)
|
||||||
pixelformatIyuv, //Planar mode: Y + U + V (3 planes)
|
pixelformatIyuv = 0x56555949, //Planar mode: Y + U + V (3 planes)
|
||||||
pixelformatYuy2, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
pixelformatYuy2 = 0x32595559, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
||||||
pixelformatUyvy, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
pixelformatUyvy = 0x59565955, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
||||||
pixelformatYvyu, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
pixelformatYvyu = 0x55595659, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
||||||
pixelformatNv12, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatNv12 = 0x3231564e, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatNv21, //Planar mode: Y + V/U interleaved (2 planes)
|
pixelformatNv21 = 0x3132564e, //Planar mode: Y + V/U interleaved (2 planes)
|
||||||
pixelformatP010, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatP010 = 0x30313050, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatExternalOes, //Android video texture format
|
pixelformatExternalOes = 0x2053454f, //Android video texture format
|
||||||
pixelformatMjpg, //Motion JPEG
|
pixelformatMjpg = 0x47504a4d, //Motion JPEG
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Surface = opaque {};
|
pub const Surface = opaque {};
|
||||||
|
|
||||||
pub const Colorspace = enum(c_int) {
|
pub const Colorspace = enum(c_int) {
|
||||||
colorspaceSrgb, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
colorspaceSrgb = 0x120005a0, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
||||||
colorRangeFull,
|
colorRangeFull,
|
||||||
colorPrimariesBt709,
|
colorPrimariesBt709,
|
||||||
transferCharacteristicsSrgb,
|
transferCharacteristicsSrgb,
|
||||||
matrixCoefficientsIdentity,
|
matrixCoefficientsIdentity,
|
||||||
colorspaceSrgbLinear, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
colorspaceSrgbLinear = 0x12000500, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
||||||
transferCharacteristicsLinear,
|
transferCharacteristicsLinear,
|
||||||
colorspaceHdr10, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
colorspaceHdr10 = 0x12002600, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
||||||
colorPrimariesBt2020,
|
colorPrimariesBt2020,
|
||||||
transferCharacteristicsPq,
|
transferCharacteristicsPq,
|
||||||
colorspaceJpeg, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
colorspaceJpeg = 0x220004c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
||||||
transferCharacteristicsBt601,
|
transferCharacteristicsBt601,
|
||||||
matrixCoefficientsBt601,
|
matrixCoefficientsBt601,
|
||||||
colorspaceBt601Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
colorspaceBt601Limited = 0x211018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
||||||
colorRangeLimited,
|
colorRangeLimited,
|
||||||
colorPrimariesBt601,
|
colorPrimariesBt601,
|
||||||
colorspaceBt601Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
colorspaceBt601Full = 0x221018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
||||||
colorspaceBt709Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
colorspaceBt709Limited = 0x21100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
||||||
transferCharacteristicsBt709,
|
transferCharacteristicsBt709,
|
||||||
matrixCoefficientsBt709,
|
matrixCoefficientsBt709,
|
||||||
colorspaceBt709Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
colorspaceBt709Full = 0x22100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
||||||
colorspaceBt2020Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
colorspaceBt2020Limited = 0x21102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
||||||
matrixCoefficientsBt2020Ncl,
|
matrixCoefficientsBt2020Ncl,
|
||||||
colorspaceBt2020Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
colorspaceBt2020Full = 0x22102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
||||||
colorspaceRgbDefault, //The default colorspace for RGB surfaces if no colorspace is specified
|
|
||||||
colorspaceYuvDefault, //The default colorspace for YUV surfaces if no colorspace is specified
|
pub const colorspaceRgbDefault = .colorspaceSrgb; //The default colorspace for RGB surfaces if no colorspace is specified
|
||||||
|
pub const colorspaceYuvDefault = .colorspaceBt601Limited; //The default colorspace for YUV surfaces if no colorspace is specified
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PropertiesID = u32;
|
pub const PropertiesID = u32;
|
||||||
|
|
@ -50,32 +51,32 @@ pub const PropertiesID = u32;
|
||||||
pub const CameraID = u32;
|
pub const CameraID = u32;
|
||||||
|
|
||||||
pub const Camera = opaque {
|
pub const Camera = opaque {
|
||||||
pub inline fn getCameraPermissionState(camera: *Camera) c_int {
|
pub inline fn getCameraPermissionState(camera: *Camera) CameraPermissionState {
|
||||||
return c.SDL_GetCameraPermissionState(camera);
|
return c.SDL_GetCameraPermissionState(@ptrCast(camera));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraID(camera: *Camera) CameraID {
|
pub inline fn getCameraID(camera: *Camera) CameraID {
|
||||||
return c.SDL_GetCameraID(camera);
|
return c.SDL_GetCameraID(@ptrCast(camera));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraProperties(camera: *Camera) PropertiesID {
|
pub inline fn getCameraProperties(camera: *Camera) PropertiesID {
|
||||||
return c.SDL_GetCameraProperties(camera);
|
return c.SDL_GetCameraProperties(@ptrCast(camera));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameraFormat(camera: *Camera, spec: ?*CameraSpec) bool {
|
pub inline fn getCameraFormat(camera: *Camera, spec: ?*CameraSpec) bool {
|
||||||
return c.SDL_GetCameraFormat(camera, spec);
|
return @bitCast(c.SDL_GetCameraFormat(@ptrCast(camera), @ptrCast(spec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn acquireCameraFrame(camera: *Camera, timestampNS: *u64) ?*Surface {
|
pub inline fn acquireCameraFrame(camera: *Camera, timestampNS: *u64) ?*Surface {
|
||||||
return c.SDL_AcquireCameraFrame(camera, @ptrCast(timestampNS));
|
return @ptrCast(c.SDL_AcquireCameraFrame(@ptrCast(camera), @ptrCast(timestampNS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseCameraFrame(camera: *Camera, frame: ?*Surface) void {
|
pub inline fn releaseCameraFrame(camera: *Camera, frame: ?*Surface) void {
|
||||||
return c.SDL_ReleaseCameraFrame(camera, frame);
|
return c.SDL_ReleaseCameraFrame(@ptrCast(camera), @ptrCast(frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeCamera(camera: *Camera) void {
|
pub inline fn closeCamera(camera: *Camera) void {
|
||||||
return c.SDL_CloseCamera(camera);
|
return c.SDL_CloseCamera(@ptrCast(camera));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -94,6 +95,11 @@ pub const CameraPosition = enum(c_int) {
|
||||||
cameraPositionBackFacing,
|
cameraPositionBackFacing,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const CameraPermissionState = enum(c_int) {
|
||||||
|
cameraPermissionStatePending,
|
||||||
|
cameraPermissionStateApproved,
|
||||||
|
};
|
||||||
|
|
||||||
pub inline fn getNumCameraDrivers() c_int {
|
pub inline fn getNumCameraDrivers() c_int {
|
||||||
return c.SDL_GetNumCameraDrivers();
|
return c.SDL_GetNumCameraDrivers();
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +113,7 @@ pub inline fn getCurrentCameraDriver() [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCameras(count: *c_int) ?*CameraID {
|
pub inline fn getCameras(count: *c_int) ?*CameraID {
|
||||||
return 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][*c]CameraSpec {
|
||||||
|
|
@ -123,5 +129,5 @@ pub inline fn getCameraPosition(instance_id: CameraID) CameraPosition {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openCamera(instance_id: CameraID, spec: *const CameraSpec) ?*Camera {
|
pub inline fn openCamera(instance_id: CameraID, spec: *const CameraSpec) ?*Camera {
|
||||||
return c.SDL_OpenCamera(instance_id, @ptrCast(spec));
|
return @ptrCast(c.SDL_OpenCamera(instance_id, @ptrCast(spec)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub inline fn setClipboardText(text: [*c]const u8) bool {
|
pub inline fn setClipboardText(text: [*c]const u8) bool {
|
||||||
return c.SDL_SetClipboardText(text);
|
return @bitCast(c.SDL_SetClipboardText(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getClipboardText() [*c]u8 {
|
pub inline fn getClipboardText() [*c]u8 {
|
||||||
|
|
@ -10,11 +10,11 @@ pub inline fn getClipboardText() [*c]u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasClipboardText() bool {
|
pub inline fn hasClipboardText() bool {
|
||||||
return c.SDL_HasClipboardText();
|
return @bitCast(c.SDL_HasClipboardText());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setPrimarySelectionText(text: [*c]const u8) bool {
|
pub inline fn setPrimarySelectionText(text: [*c]const u8) bool {
|
||||||
return c.SDL_SetPrimarySelectionText(text);
|
return @bitCast(c.SDL_SetPrimarySelectionText(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPrimarySelectionText() [*c]u8 {
|
pub inline fn getPrimarySelectionText() [*c]u8 {
|
||||||
|
|
@ -22,7 +22,7 @@ pub inline fn getPrimarySelectionText() [*c]u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasPrimarySelectionText() bool {
|
pub inline fn hasPrimarySelectionText() bool {
|
||||||
return c.SDL_HasPrimarySelectionText();
|
return @bitCast(c.SDL_HasPrimarySelectionText());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const ClipboardDataCallback = c.SDL_ClipboardDataCallback;
|
pub const ClipboardDataCallback = c.SDL_ClipboardDataCallback;
|
||||||
|
|
@ -30,11 +30,11 @@ pub const ClipboardDataCallback = c.SDL_ClipboardDataCallback;
|
||||||
pub const ClipboardCleanupCallback = c.SDL_ClipboardCleanupCallback;
|
pub const ClipboardCleanupCallback = c.SDL_ClipboardCleanupCallback;
|
||||||
|
|
||||||
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);
|
return @bitCast(c.SDL_SetClipboardData(callback, cleanup, userdata, mime_types, num_mime_types));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn clearClipboardData() bool {
|
pub inline fn clearClipboardData() bool {
|
||||||
return c.SDL_ClearClipboardData();
|
return @bitCast(c.SDL_ClearClipboardData());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getClipboardData(mime_type: [*c]const u8, size: *usize) ?*anyopaque {
|
pub inline fn getClipboardData(mime_type: [*c]const u8, size: *usize) ?*anyopaque {
|
||||||
|
|
@ -42,7 +42,7 @@ pub inline fn getClipboardData(mime_type: [*c]const u8, size: *usize) ?*anyopaqu
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasClipboardData(mime_type: [*c]const u8) bool {
|
pub inline fn hasClipboardData(mime_type: [*c]const u8) bool {
|
||||||
return c.SDL_HasClipboardData(mime_type);
|
return @bitCast(c.SDL_HasClipboardData(mime_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getClipboardMimeTypes(num_mime_types: *usize) [*c][*c]u8 {
|
pub inline fn getClipboardMimeTypes(num_mime_types: *usize) [*c][*c]u8 {
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,15 @@ 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, window, @ptrCast(filters), nfilters, default_location, 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, window, @ptrCast(filters), nfilters, default_location);
|
return c.SDL_ShowSaveFileDialog(callback, userdata, @ptrCast(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);
|
return c.SDL_ShowOpenFolderDialog(callback, userdata, @ptrCast(window), default_location, @bitCast(allow_many));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const FileDialogType = enum(c_int) {
|
pub const FileDialogType = enum(c_int) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub inline fn outOfMemory() bool {
|
pub inline fn outOfMemory() bool {
|
||||||
return c.SDL_OutOfMemory();
|
return @bitCast(c.SDL_OutOfMemory());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getError() [*c]const u8 {
|
pub inline fn getError() [*c]const u8 {
|
||||||
|
|
@ -10,5 +10,5 @@ pub inline fn getError() [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn clearError() bool {
|
pub inline fn clearError() bool {
|
||||||
return c.SDL_ClearError();
|
return @bitCast(c.SDL_ClearError());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
230
api/events.zig
230
api/events.zig
|
|
@ -19,8 +19,11 @@ pub const PenInputFlags = packed struct(u32) {
|
||||||
penInputButton4: bool = false, // button 4 is pressed
|
penInputButton4: bool = false, // button 4 is pressed
|
||||||
penInputButton5: bool = false, // button 5 is pressed
|
penInputButton5: bool = false, // button 5 is pressed
|
||||||
penInputEraserTip: bool = false, // eraser tip is used
|
penInputEraserTip: bool = false, // eraser tip is used
|
||||||
pad0: u24 = 0,
|
penInputInProximity: bool = false, // pen is in proximity (since SDL 3.4.0)
|
||||||
|
pad0: u23 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = PenInputFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MouseButtonFlags = packed struct(u32) {
|
pub const MouseButtonFlags = packed struct(u32) {
|
||||||
|
|
@ -29,79 +32,81 @@ pub const MouseButtonFlags = packed struct(u32) {
|
||||||
buttonX1: bool = false,
|
buttonX1: bool = false,
|
||||||
pad0: u28 = 0,
|
pad0: u28 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = MouseButtonFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Scancode = enum(c_int) {
|
pub const Scancode = enum(c_int) {
|
||||||
scancodeBackslash,
|
scancodeBackslash = 49,
|
||||||
scancodeNonushash,
|
scancodeNonushash = 50,
|
||||||
scancodeGrave,
|
scancodeGrave = 53,
|
||||||
scancodeInsert,
|
scancodeInsert = 73,
|
||||||
scancodeNumlockclear,
|
scancodeNumlockclear = 83,
|
||||||
scancodeNonusbackslash,
|
scancodeNonusbackslash = 100,
|
||||||
scancodeApplication, //windows contextual menu, compose
|
scancodeApplication = 101, //windows contextual menu, compose
|
||||||
scancodePower,
|
scancodePower = 102,
|
||||||
scancodeHelp, //AL Integrated Help Center
|
scancodeHelp = 117, //AL Integrated Help Center
|
||||||
scancodeMenu, //Menu (show menu)
|
scancodeMenu = 118, //Menu (show menu)
|
||||||
scancodeStop, //AC Stop
|
scancodeStop = 120, //AC Stop
|
||||||
scancodeAgain, //AC Redo/Repeat
|
scancodeAgain = 121, //AC Redo/Repeat
|
||||||
scancodeUndo, //AC Undo
|
scancodeUndo = 122, //AC Undo
|
||||||
scancodeCut, //AC Cut
|
scancodeCut = 123, //AC Cut
|
||||||
scancodeCopy, //AC Copy
|
scancodeCopy = 124, //AC Copy
|
||||||
scancodePaste, //AC Paste
|
scancodePaste = 125, //AC Paste
|
||||||
scancodeFind, //AC Find
|
scancodeFind = 126, //AC Find
|
||||||
scancodeInternational1,
|
scancodeInternational1 = 135,
|
||||||
scancodeInternational3, //Yen
|
scancodeInternational3 = 137, //Yen
|
||||||
scancodeLang1, //Hangul/English toggle
|
scancodeLang1 = 144, //Hangul/English toggle
|
||||||
scancodeLang2, //Hanja conversion
|
scancodeLang2 = 145, //Hanja conversion
|
||||||
scancodeLang3, //Katakana
|
scancodeLang3 = 146, //Katakana
|
||||||
scancodeLang4, //Hiragana
|
scancodeLang4 = 147, //Hiragana
|
||||||
scancodeLang5, //Zenkaku/Hankaku
|
scancodeLang5 = 148, //Zenkaku/Hankaku
|
||||||
scancodeLang6, //reserved
|
scancodeLang6 = 149, //reserved
|
||||||
scancodeLang7, //reserved
|
scancodeLang7 = 150, //reserved
|
||||||
scancodeLang8, //reserved
|
scancodeLang8 = 151, //reserved
|
||||||
scancodeLang9, //reserved
|
scancodeLang9 = 152, //reserved
|
||||||
scancodeAlterase, //Erase-Eaze
|
scancodeAlterase = 153, //Erase-Eaze
|
||||||
scancodeCancel, //AC Cancel
|
scancodeCancel = 155, //AC Cancel
|
||||||
scancodeLalt, //alt, option
|
scancodeLalt = 226, //alt, option
|
||||||
scancodeLgui, //windows, command (apple), meta
|
scancodeLgui = 227, //windows, command (apple), meta
|
||||||
scancodeRalt, //alt gr, option
|
scancodeRalt = 230, //alt gr, option
|
||||||
scancodeRgui, //windows, command (apple), meta
|
scancodeRgui = 231, //windows, command (apple), meta
|
||||||
scancodeMode,
|
scancodeMode = 257,
|
||||||
scancodeSleep, //Sleep
|
scancodeSleep = 258, //Sleep
|
||||||
scancodeWake, //Wake
|
scancodeWake = 259, //Wake
|
||||||
scancodeChannelIncrement, //Channel Increment
|
scancodeChannelIncrement = 260, //Channel Increment
|
||||||
scancodeChannelDecrement, //Channel Decrement
|
scancodeChannelDecrement = 261, //Channel Decrement
|
||||||
scancodeMediaPlay, //Play
|
scancodeMediaPlay = 262, //Play
|
||||||
scancodeMediaPause, //Pause
|
scancodeMediaPause = 263, //Pause
|
||||||
scancodeMediaRecord, //Record
|
scancodeMediaRecord = 264, //Record
|
||||||
scancodeMediaFastForward, //Fast Forward
|
scancodeMediaFastForward = 265, //Fast Forward
|
||||||
scancodeMediaRewind, //Rewind
|
scancodeMediaRewind = 266, //Rewind
|
||||||
scancodeMediaNextTrack, //Next Track
|
scancodeMediaNextTrack = 267, //Next Track
|
||||||
scancodeMediaPreviousTrack, //Previous Track
|
scancodeMediaPreviousTrack = 268, //Previous Track
|
||||||
scancodeMediaStop, //Stop
|
scancodeMediaStop = 269, //Stop
|
||||||
scancodeMediaEject, //Eject
|
scancodeMediaEject = 270, //Eject
|
||||||
scancodeMediaPlayPause, //Play / Pause
|
scancodeMediaPlayPause = 271, //Play / Pause
|
||||||
scancodeMediaSelect,
|
scancodeMediaSelect = 272,
|
||||||
scancodeAcNew, //AC New
|
scancodeAcNew = 273, //AC New
|
||||||
scancodeAcOpen, //AC Open
|
scancodeAcOpen = 274, //AC Open
|
||||||
scancodeAcClose, //AC Close
|
scancodeAcClose = 275, //AC Close
|
||||||
scancodeAcExit, //AC Exit
|
scancodeAcExit = 276, //AC Exit
|
||||||
scancodeAcSave, //AC Save
|
scancodeAcSave = 277, //AC Save
|
||||||
scancodeAcPrint, //AC Print
|
scancodeAcPrint = 278, //AC Print
|
||||||
scancodeAcProperties, //AC Properties
|
scancodeAcProperties = 279, //AC Properties
|
||||||
scancodeAcSearch, //AC Search
|
scancodeAcSearch = 280, //AC Search
|
||||||
scancodeAcHome, //AC Home
|
scancodeAcHome = 281, //AC Home
|
||||||
scancodeAcBack, //AC Back
|
scancodeAcBack = 282, //AC Back
|
||||||
scancodeAcForward, //AC Forward
|
scancodeAcForward = 283, //AC Forward
|
||||||
scancodeAcStop, //AC Stop
|
scancodeAcStop = 284, //AC Stop
|
||||||
scancodeAcRefresh, //AC Refresh
|
scancodeAcRefresh = 285, //AC Refresh
|
||||||
scancodeAcBookmarks, //AC Bookmarks
|
scancodeAcBookmarks = 286, //AC Bookmarks
|
||||||
scancodeSoftleft,
|
scancodeSoftleft = 287,
|
||||||
scancodeSoftright,
|
scancodeSoftright = 288,
|
||||||
scancodeCall, //Used for accepting phone calls.
|
scancodeCall = 289, //Used for accepting phone calls.
|
||||||
scancodeEndcall, //Used for rejecting phone calls.
|
scancodeEndcall = 290, //Used for rejecting phone calls.
|
||||||
scancodeReserved, //400-500 reserved for dynamic keycodes
|
scancodeReserved = 400, //400-500 reserved for dynamic keycodes
|
||||||
scancodeCount,
|
scancodeCount = 512,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TouchID = u64;
|
pub const TouchID = u64;
|
||||||
|
|
@ -127,7 +132,7 @@ pub const MouseWheelDirection = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PowerState = enum(c_int) {
|
pub const PowerState = enum(c_int) {
|
||||||
powerstateError, //error determining power status
|
powerstateError = -1, //error determining power status
|
||||||
powerstateUnknown, //cannot determine power status
|
powerstateUnknown, //cannot determine power status
|
||||||
powerstateOnBattery, //Not plugged in, running on the battery
|
powerstateOnBattery, //Not plugged in, running on the battery
|
||||||
powerstateNoBattery, //Plugged in, no battery available
|
powerstateNoBattery, //Plugged in, no battery available
|
||||||
|
|
@ -148,8 +153,8 @@ pub const JoystickID = u32;
|
||||||
pub const Keymod = u16;
|
pub const Keymod = u16;
|
||||||
|
|
||||||
pub const EventType = enum(c_int) {
|
pub const EventType = enum(c_int) {
|
||||||
eventFirst, //Unused (do not remove)
|
eventFirst = 0, //Unused (do not remove)
|
||||||
eventQuit, //User-requested quit
|
eventQuit = 0x100, //User-requested quit
|
||||||
eventTerminating,
|
eventTerminating,
|
||||||
eventLowMemory,
|
eventLowMemory,
|
||||||
eventWillEnterBackground,
|
eventWillEnterBackground,
|
||||||
|
|
@ -158,16 +163,17 @@ pub const EventType = enum(c_int) {
|
||||||
eventDidEnterForeground,
|
eventDidEnterForeground,
|
||||||
eventLocaleChanged, //The user's locale preferences have changed.
|
eventLocaleChanged, //The user's locale preferences have changed.
|
||||||
eventSystemThemeChanged, //The system theme changed
|
eventSystemThemeChanged, //The system theme changed
|
||||||
eventDisplayOrientation, //Display orientation has changed to data1
|
eventDisplayOrientation = 0x151, //Display orientation has changed to data1
|
||||||
eventDisplayAdded, //Display has been added to the system
|
eventDisplayAdded, //Display has been added to the system
|
||||||
eventDisplayRemoved, //Display has been removed from the system
|
eventDisplayRemoved, //Display has been removed from the system
|
||||||
eventDisplayMoved, //Display has changed position
|
eventDisplayMoved, //Display has changed position
|
||||||
eventDisplayDesktopModeChanged, //Display has changed desktop mode
|
eventDisplayDesktopModeChanged, //Display has changed desktop mode
|
||||||
eventDisplayCurrentModeChanged, //Display has changed current mode
|
eventDisplayCurrentModeChanged, //Display has changed current mode
|
||||||
eventDisplayContentScaleChanged, //Display has changed content scale
|
eventDisplayContentScaleChanged, //Display has changed content scale
|
||||||
eventWindowShown, //Window has been shown
|
eventDisplayUsableBoundsChanged, //Display has changed usable bounds
|
||||||
|
eventWindowShown = 0x202, //Window has been shown
|
||||||
eventWindowHidden, //Window has been hidden
|
eventWindowHidden, //Window has been hidden
|
||||||
eventWindowExposed, //Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event
|
eventWindowExposed,
|
||||||
eventWindowMoved, //Window has been moved to data1, data2
|
eventWindowMoved, //Window has been moved to data1, data2
|
||||||
eventWindowResized, //Window has been resized to data1xdata2
|
eventWindowResized, //Window has been resized to data1xdata2
|
||||||
eventWindowPixelSizeChanged, //The pixel size of the window has changed to data1xdata2
|
eventWindowPixelSizeChanged, //The pixel size of the window has changed to data1xdata2
|
||||||
|
|
@ -190,7 +196,7 @@ pub const EventType = enum(c_int) {
|
||||||
eventWindowLeaveFullscreen, //The window has left fullscreen mode
|
eventWindowLeaveFullscreen, //The window has left fullscreen mode
|
||||||
eventWindowDestroyed,
|
eventWindowDestroyed,
|
||||||
eventWindowHdrStateChanged, //Window HDR properties have changed
|
eventWindowHdrStateChanged, //Window HDR properties have changed
|
||||||
eventKeyDown, //Key pressed
|
eventKeyDown = 0x300, //Key pressed
|
||||||
eventKeyUp, //Key released
|
eventKeyUp, //Key released
|
||||||
eventTextEditing, //Keyboard text editing (composition)
|
eventTextEditing, //Keyboard text editing (composition)
|
||||||
eventTextInput, //Keyboard text input
|
eventTextInput, //Keyboard text input
|
||||||
|
|
@ -198,13 +204,15 @@ pub const EventType = enum(c_int) {
|
||||||
eventKeyboardAdded, //A new keyboard has been inserted into the system
|
eventKeyboardAdded, //A new keyboard has been inserted into the system
|
||||||
eventKeyboardRemoved, //A keyboard has been removed
|
eventKeyboardRemoved, //A keyboard has been removed
|
||||||
eventTextEditingCandidates, //Keyboard text editing candidates
|
eventTextEditingCandidates, //Keyboard text editing candidates
|
||||||
eventMouseMotion, //Mouse moved
|
eventScreenKeyboardShown, //The on-screen keyboard has been shown
|
||||||
|
eventScreenKeyboardHidden, //The on-screen keyboard has been hidden
|
||||||
|
eventMouseMotion = 0x400, //Mouse moved
|
||||||
eventMouseButtonDown, //Mouse button pressed
|
eventMouseButtonDown, //Mouse button pressed
|
||||||
eventMouseButtonUp, //Mouse button released
|
eventMouseButtonUp, //Mouse button released
|
||||||
eventMouseWheel, //Mouse wheel motion
|
eventMouseWheel, //Mouse wheel motion
|
||||||
eventMouseAdded, //A new mouse has been inserted into the system
|
eventMouseAdded, //A new mouse has been inserted into the system
|
||||||
eventMouseRemoved, //A mouse has been removed
|
eventMouseRemoved, //A mouse has been removed
|
||||||
eventJoystickAxisMotion, //Joystick axis motion
|
eventJoystickAxisMotion = 0x600, //Joystick axis motion
|
||||||
eventJoystickBallMotion, //Joystick trackball motion
|
eventJoystickBallMotion, //Joystick trackball motion
|
||||||
eventJoystickHatMotion, //Joystick hat position change
|
eventJoystickHatMotion, //Joystick hat position change
|
||||||
eventJoystickButtonDown, //Joystick button pressed
|
eventJoystickButtonDown, //Joystick button pressed
|
||||||
|
|
@ -213,7 +221,7 @@ pub const EventType = enum(c_int) {
|
||||||
eventJoystickRemoved, //An opened joystick has been removed
|
eventJoystickRemoved, //An opened joystick has been removed
|
||||||
eventJoystickBatteryUpdated, //Joystick battery level change
|
eventJoystickBatteryUpdated, //Joystick battery level change
|
||||||
eventJoystickUpdateComplete, //Joystick update is complete
|
eventJoystickUpdateComplete, //Joystick update is complete
|
||||||
eventGamepadAxisMotion, //Gamepad axis motion
|
eventGamepadAxisMotion = 0x650, //Gamepad axis motion
|
||||||
eventGamepadButtonDown, //Gamepad button pressed
|
eventGamepadButtonDown, //Gamepad button pressed
|
||||||
eventGamepadButtonUp, //Gamepad button released
|
eventGamepadButtonUp, //Gamepad button released
|
||||||
eventGamepadAdded, //A new gamepad has been inserted into the system
|
eventGamepadAdded, //A new gamepad has been inserted into the system
|
||||||
|
|
@ -228,17 +236,20 @@ pub const EventType = enum(c_int) {
|
||||||
eventFingerUp,
|
eventFingerUp,
|
||||||
eventFingerMotion,
|
eventFingerMotion,
|
||||||
eventFingerCanceled,
|
eventFingerCanceled,
|
||||||
eventClipboardUpdate, //The clipboard or primary selection changed
|
eventPinchBegin = 0x710, //Pinch gesture started
|
||||||
eventDropFile, //The system requests a file open
|
eventPinchUpdate, //Pinch gesture updated
|
||||||
|
eventPinchEnd, //Pinch gesture ended
|
||||||
|
eventClipboardUpdate = 0x900, //The clipboard changed
|
||||||
|
eventDropFile = 0x1000, //The system requests a file open
|
||||||
eventDropText, //text/plain drag-and-drop event
|
eventDropText, //text/plain drag-and-drop event
|
||||||
eventDropBegin, //A new set of drops is beginning (NULL filename)
|
eventDropBegin, //A new set of drops is beginning (NULL filename)
|
||||||
eventDropComplete, //Current set of drops is now complete (NULL filename)
|
eventDropComplete, //Current set of drops is now complete (NULL filename)
|
||||||
eventDropPosition, //Position while moving over the window
|
eventDropPosition, //Position while moving over the window
|
||||||
eventAudioDeviceAdded, //A new audio device is available
|
eventAudioDeviceAdded = 0x1100, //A new audio device is available
|
||||||
eventAudioDeviceRemoved, //An audio device has been removed.
|
eventAudioDeviceRemoved, //An audio device has been removed.
|
||||||
eventAudioDeviceFormatChanged, //An audio device's format has been changed by the system.
|
eventAudioDeviceFormatChanged, //An audio device's format has been changed by the system.
|
||||||
eventSensorUpdate, //A sensor was updated
|
eventSensorUpdate = 0x1200, //A sensor was updated
|
||||||
eventPenProximityIn, //Pressure-sensitive pen has become available
|
eventPenProximityIn = 0x1300, //Pressure-sensitive pen has become available
|
||||||
eventPenProximityOut, //Pressure-sensitive pen has become unavailable
|
eventPenProximityOut, //Pressure-sensitive pen has become unavailable
|
||||||
eventPenDown, //Pressure-sensitive pen touched drawing surface
|
eventPenDown, //Pressure-sensitive pen touched drawing surface
|
||||||
eventPenUp, //Pressure-sensitive pen stopped touching drawing surface
|
eventPenUp, //Pressure-sensitive pen stopped touching drawing surface
|
||||||
|
|
@ -246,17 +257,17 @@ pub const EventType = enum(c_int) {
|
||||||
eventPenButtonUp, //Pressure-sensitive pen button released
|
eventPenButtonUp, //Pressure-sensitive pen button released
|
||||||
eventPenMotion, //Pressure-sensitive pen is moving on the tablet
|
eventPenMotion, //Pressure-sensitive pen is moving on the tablet
|
||||||
eventPenAxis, //Pressure-sensitive pen angle/pressure/etc changed
|
eventPenAxis, //Pressure-sensitive pen angle/pressure/etc changed
|
||||||
eventCameraDeviceAdded, //A new camera device is available
|
eventCameraDeviceAdded = 0x1400, //A new camera device is available
|
||||||
eventCameraDeviceRemoved, //A camera device has been removed.
|
eventCameraDeviceRemoved, //A camera device has been removed.
|
||||||
eventCameraDeviceApproved, //A camera device has been approved for use by the user.
|
eventCameraDeviceApproved, //A camera device has been approved for use by the user.
|
||||||
eventCameraDeviceDenied, //A camera device has been denied for use by the user.
|
eventCameraDeviceDenied, //A camera device has been denied for use by the user.
|
||||||
eventRenderTargetsReset, //The render targets have been reset and their contents need to be updated
|
eventRenderTargetsReset = 0x2000, //The render targets have been reset and their contents need to be updated
|
||||||
eventRenderDeviceReset, //The device has been reset and all textures need to be recreated
|
eventRenderDeviceReset, //The device has been reset and all textures need to be recreated
|
||||||
eventRenderDeviceLost, //The device has been lost and can't be recovered.
|
eventRenderDeviceLost, //The device has been lost and can't be recovered.
|
||||||
eventPrivate1,
|
eventPrivate1,
|
||||||
eventPrivate2,
|
eventPrivate2,
|
||||||
eventPrivate3,
|
eventPrivate3,
|
||||||
eventPollSentinel, //Signals the end of an event poll cycle
|
eventPollSentinel = 0x7F00, //Signals the end of an event poll cycle
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const CommonEvent = extern struct {
|
pub const CommonEvent = extern struct {
|
||||||
|
|
@ -266,7 +277,7 @@ pub const CommonEvent = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DisplayEvent = extern struct {
|
pub const DisplayEvent = extern struct {
|
||||||
_type: EventType, // SDL_DISPLAYEVENT_*
|
_type: EventType, // SDL_EVENT_DISPLAY_*
|
||||||
reserved: u32,
|
reserved: u32,
|
||||||
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
||||||
displayID: DisplayID, // The associated display
|
displayID: DisplayID, // The associated display
|
||||||
|
|
@ -540,6 +551,14 @@ pub const TouchFingerEvent = extern struct {
|
||||||
windowID: WindowID, // The window underneath the finger, if any
|
windowID: WindowID, // The window underneath the finger, if any
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const PinchFingerEvent = extern struct {
|
||||||
|
_type: EventType, // ::SDL_EVENT_PINCH_BEGIN or ::SDL_EVENT_PINCH_UPDATE or ::SDL_EVENT_PINCH_END
|
||||||
|
reserved: u32,
|
||||||
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
||||||
|
scale: f32, // The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is "zoom out". Scale > 1 is "zoom in".
|
||||||
|
windowID: WindowID, // The window underneath the finger, if any
|
||||||
|
};
|
||||||
|
|
||||||
pub const PenProximityEvent = extern struct {
|
pub const PenProximityEvent = extern struct {
|
||||||
_type: EventType, // SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT
|
_type: EventType, // SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT
|
||||||
reserved: u32,
|
reserved: u32,
|
||||||
|
|
@ -634,7 +653,7 @@ pub const QuitEvent = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const UserEvent = extern struct {
|
pub const UserEvent = extern struct {
|
||||||
_type: u32, // SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration
|
_type: u32, // SDL_EVENT_USER through SDL_EVENT_LAST, Uint32 because these are not in the SDL_EventType enumeration
|
||||||
reserved: u32,
|
reserved: u32,
|
||||||
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
||||||
windowID: WindowID, // The associated window if any
|
windowID: WindowID, // The associated window if any
|
||||||
|
|
@ -674,6 +693,7 @@ pub const Event = extern union {
|
||||||
quit: QuitEvent, // Quit request event data
|
quit: QuitEvent, // Quit request event data
|
||||||
user: UserEvent, // Custom event data
|
user: UserEvent, // Custom event data
|
||||||
tfinger: TouchFingerEvent, // Touch finger event data
|
tfinger: TouchFingerEvent, // Touch finger event data
|
||||||
|
pinch: PinchFingerEvent, // Pinch event data
|
||||||
pproximity: PenProximityEvent, // Pen proximity event data
|
pproximity: PenProximityEvent, // Pen proximity event data
|
||||||
ptouch: PenTouchEvent, // Pen tip touching event data
|
ptouch: PenTouchEvent, // Pen tip touching event data
|
||||||
pmotion: PenMotionEvent, // Pen motion event data
|
pmotion: PenMotionEvent, // Pen motion event data
|
||||||
|
|
@ -696,15 +716,15 @@ pub const EventAction = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn peepEvents(events: ?*Event, numevents: c_int, action: EventAction, minType: u32, maxType: u32) c_int {
|
pub inline fn peepEvents(events: ?*Event, numevents: c_int, action: EventAction, minType: u32, maxType: u32) c_int {
|
||||||
return c.SDL_PeepEvents(events, numevents, action, minType, maxType);
|
return c.SDL_PeepEvents(@ptrCast(events), numevents, action, minType, maxType);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasEvent(_type: u32) bool {
|
pub inline fn hasEvent(_type: u32) bool {
|
||||||
return c.SDL_HasEvent(_type);
|
return @bitCast(c.SDL_HasEvent(_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasEvents(minType: u32, maxType: u32) bool {
|
pub inline fn hasEvents(minType: u32, maxType: u32) bool {
|
||||||
return c.SDL_HasEvents(minType, maxType);
|
return @bitCast(c.SDL_HasEvents(minType, maxType));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn flushEvent(_type: u32) void {
|
pub inline fn flushEvent(_type: u32) void {
|
||||||
|
|
@ -716,19 +736,19 @@ pub inline fn flushEvents(minType: u32, maxType: u32) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pollEvent(event: ?*Event) bool {
|
pub inline fn pollEvent(event: ?*Event) bool {
|
||||||
return c.SDL_PollEvent(event);
|
return @bitCast(c.SDL_PollEvent(@ptrCast(event)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitEvent(event: ?*Event) bool {
|
pub inline fn waitEvent(event: ?*Event) bool {
|
||||||
return c.SDL_WaitEvent(event);
|
return @bitCast(c.SDL_WaitEvent(@ptrCast(event)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitEventTimeout(event: ?*Event, timeoutMS: i32) bool {
|
pub inline fn waitEventTimeout(event: ?*Event, timeoutMS: i32) bool {
|
||||||
return c.SDL_WaitEventTimeout(event, timeoutMS);
|
return @bitCast(c.SDL_WaitEventTimeout(@ptrCast(event), timeoutMS));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pushEvent(event: ?*Event) bool {
|
pub inline fn pushEvent(event: ?*Event) bool {
|
||||||
return c.SDL_PushEvent(event);
|
return @bitCast(c.SDL_PushEvent(@ptrCast(event)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const EventFilter = c.SDL_EventFilter;
|
pub const EventFilter = c.SDL_EventFilter;
|
||||||
|
|
@ -738,11 +758,11 @@ pub inline fn setEventFilter(filter: EventFilter, userdata: ?*anyopaque) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getEventFilter(filter: ?*EventFilter, userdata: [*c]?*anyopaque) bool {
|
pub inline fn getEventFilter(filter: ?*EventFilter, userdata: [*c]?*anyopaque) bool {
|
||||||
return c.SDL_GetEventFilter(filter, userdata);
|
return @bitCast(c.SDL_GetEventFilter(@ptrCast(filter), userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn addEventWatch(filter: EventFilter, userdata: ?*anyopaque) bool {
|
pub inline fn addEventWatch(filter: EventFilter, userdata: ?*anyopaque) bool {
|
||||||
return c.SDL_AddEventWatch(filter, userdata);
|
return @bitCast(c.SDL_AddEventWatch(filter, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removeEventWatch(filter: EventFilter, userdata: ?*anyopaque) void {
|
pub inline fn removeEventWatch(filter: EventFilter, userdata: ?*anyopaque) void {
|
||||||
|
|
@ -754,11 +774,11 @@ pub inline fn filterEvents(filter: EventFilter, userdata: ?*anyopaque) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setEventEnabled(_type: u32, enabled: bool) void {
|
pub inline fn setEventEnabled(_type: u32, enabled: bool) void {
|
||||||
return c.SDL_SetEventEnabled(_type, enabled);
|
return c.SDL_SetEventEnabled(_type, @bitCast(enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn eventEnabled(_type: u32) bool {
|
pub inline fn eventEnabled(_type: u32) bool {
|
||||||
return c.SDL_EventEnabled(_type);
|
return @bitCast(c.SDL_EventEnabled(_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn registerEvents(numevents: c_int) u32 {
|
pub inline fn registerEvents(numevents: c_int) u32 {
|
||||||
|
|
@ -766,5 +786,9 @@ pub inline fn registerEvents(numevents: c_int) u32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFromEvent(event: *const Event) ?*Window {
|
pub inline fn getWindowFromEvent(event: *const Event) ?*Window {
|
||||||
return 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 {
|
||||||
|
return c.SDL_GetEventDescription(@ptrCast(event), buf, buflen);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,12 @@ pub const GlobFlags = packed struct(u32) {
|
||||||
globCaseinsensitive: bool = false,
|
globCaseinsensitive: bool = false,
|
||||||
pad0: u30 = 0,
|
pad0: u30 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = GlobFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn createDirectory(path: [*c]const u8) bool {
|
pub inline fn createDirectory(path: [*c]const u8) bool {
|
||||||
return c.SDL_CreateDirectory(path);
|
return @bitCast(c.SDL_CreateDirectory(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const EnumerationResult = enum(c_int) {
|
pub const EnumerationResult = enum(c_int) {
|
||||||
|
|
@ -64,23 +66,23 @@ pub const EnumerationResult = enum(c_int) {
|
||||||
pub const EnumerateDirectoryCallback = c.SDL_EnumerateDirectoryCallback;
|
pub const EnumerateDirectoryCallback = c.SDL_EnumerateDirectoryCallback;
|
||||||
|
|
||||||
pub inline fn enumerateDirectory(path: [*c]const u8, callback: EnumerateDirectoryCallback, userdata: ?*anyopaque) bool {
|
pub inline fn enumerateDirectory(path: [*c]const u8, callback: EnumerateDirectoryCallback, userdata: ?*anyopaque) bool {
|
||||||
return c.SDL_EnumerateDirectory(path, callback, userdata);
|
return @bitCast(c.SDL_EnumerateDirectory(path, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removePath(path: [*c]const u8) bool {
|
pub inline fn removePath(path: [*c]const u8) bool {
|
||||||
return c.SDL_RemovePath(path);
|
return @bitCast(c.SDL_RemovePath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renamePath(oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
pub inline fn renamePath(oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
||||||
return c.SDL_RenamePath(oldpath, newpath);
|
return @bitCast(c.SDL_RenamePath(oldpath, newpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn copyFile(oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
pub inline fn copyFile(oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
||||||
return c.SDL_CopyFile(oldpath, newpath);
|
return @bitCast(c.SDL_CopyFile(oldpath, newpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPathInfo(path: [*c]const u8, info: ?*PathInfo) bool {
|
pub inline fn getPathInfo(path: [*c]const u8, info: ?*PathInfo) bool {
|
||||||
return c.SDL_GetPathInfo(path, info);
|
return @bitCast(c.SDL_GetPathInfo(path, @ptrCast(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 {
|
||||||
|
|
|
||||||
119
api/gamepad.zig
119
api/gamepad.zig
|
|
@ -15,14 +15,14 @@ pub const PropertiesID = u32;
|
||||||
|
|
||||||
pub const IOStream = opaque {
|
pub const IOStream = opaque {
|
||||||
pub inline fn addGamepadMappingsFromIO(iostream: *IOStream, closeio: bool) c_int {
|
pub inline fn addGamepadMappingsFromIO(iostream: *IOStream, closeio: bool) c_int {
|
||||||
return c.SDL_AddGamepadMappingsFromIO(iostream, closeio);
|
return c.SDL_AddGamepadMappingsFromIO(@ptrCast(iostream), @bitCast(closeio));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const JoystickID = u32;
|
pub const JoystickID = u32;
|
||||||
|
|
||||||
pub const SensorType = enum(c_int) {
|
pub const SensorType = enum(c_int) {
|
||||||
sensorInvalid, //Returned for an invalid sensor
|
sensorInvalid = -1, //Returned for an invalid sensor
|
||||||
sensorUnknown, //Unknown sensor type
|
sensorUnknown, //Unknown sensor type
|
||||||
sensorAccel, //Accelerometer
|
sensorAccel, //Accelerometer
|
||||||
sensorGyro, //Gyroscope
|
sensorGyro, //Gyroscope
|
||||||
|
|
@ -34,7 +34,7 @@ pub const SensorType = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PowerState = enum(c_int) {
|
pub const PowerState = enum(c_int) {
|
||||||
powerstateError, //error determining power status
|
powerstateError = -1, //error determining power status
|
||||||
powerstateUnknown, //cannot determine power status
|
powerstateUnknown, //cannot determine power status
|
||||||
powerstateOnBattery, //Not plugged in, running on the battery
|
powerstateOnBattery, //Not plugged in, running on the battery
|
||||||
powerstateNoBattery, //Plugged in, no battery available
|
powerstateNoBattery, //Plugged in, no battery available
|
||||||
|
|
@ -46,163 +46,163 @@ pub const Joystick = opaque {};
|
||||||
|
|
||||||
pub const Gamepad = opaque {
|
pub const Gamepad = opaque {
|
||||||
pub inline fn getGamepadMapping(gamepad: *Gamepad) [*c]u8 {
|
pub inline fn getGamepadMapping(gamepad: *Gamepad) [*c]u8 {
|
||||||
return c.SDL_GetGamepadMapping(gamepad);
|
return c.SDL_GetGamepadMapping(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadProperties(gamepad: *Gamepad) PropertiesID {
|
pub inline fn getGamepadProperties(gamepad: *Gamepad) PropertiesID {
|
||||||
return c.SDL_GetGamepadProperties(gamepad);
|
return c.SDL_GetGamepadProperties(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadID(gamepad: *Gamepad) JoystickID {
|
pub inline fn getGamepadID(gamepad: *Gamepad) JoystickID {
|
||||||
return c.SDL_GetGamepadID(gamepad);
|
return c.SDL_GetGamepadID(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadName(gamepad: *Gamepad) [*c]const u8 {
|
pub inline fn getGamepadName(gamepad: *Gamepad) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadName(gamepad);
|
return c.SDL_GetGamepadName(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadPath(gamepad: *Gamepad) [*c]const u8 {
|
pub inline fn getGamepadPath(gamepad: *Gamepad) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadPath(gamepad);
|
return c.SDL_GetGamepadPath(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadType(gamepad: *Gamepad) GamepadType {
|
pub inline fn getGamepadType(gamepad: *Gamepad) GamepadType {
|
||||||
return @intFromEnum(c.SDL_GetGamepadType(gamepad));
|
return @intFromEnum(c.SDL_GetGamepadType(@ptrCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRealGamepadType(gamepad: *Gamepad) GamepadType {
|
pub inline fn getRealGamepadType(gamepad: *Gamepad) GamepadType {
|
||||||
return @intFromEnum(c.SDL_GetRealGamepadType(gamepad));
|
return @intFromEnum(c.SDL_GetRealGamepadType(@ptrCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadPlayerIndex(gamepad: *Gamepad) c_int {
|
pub inline fn getGamepadPlayerIndex(gamepad: *Gamepad) c_int {
|
||||||
return c.SDL_GetGamepadPlayerIndex(gamepad);
|
return c.SDL_GetGamepadPlayerIndex(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadPlayerIndex(gamepad: *Gamepad, player_index: c_int) bool {
|
pub inline fn setGamepadPlayerIndex(gamepad: *Gamepad, player_index: c_int) bool {
|
||||||
return c.SDL_SetGamepadPlayerIndex(gamepad, player_index);
|
return @bitCast(c.SDL_SetGamepadPlayerIndex(@ptrCast(gamepad), player_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadVendor(gamepad: *Gamepad) u16 {
|
pub inline fn getGamepadVendor(gamepad: *Gamepad) u16 {
|
||||||
return c.SDL_GetGamepadVendor(gamepad);
|
return c.SDL_GetGamepadVendor(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadProduct(gamepad: *Gamepad) u16 {
|
pub inline fn getGamepadProduct(gamepad: *Gamepad) u16 {
|
||||||
return c.SDL_GetGamepadProduct(gamepad);
|
return c.SDL_GetGamepadProduct(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadProductVersion(gamepad: *Gamepad) u16 {
|
pub inline fn getGamepadProductVersion(gamepad: *Gamepad) u16 {
|
||||||
return c.SDL_GetGamepadProductVersion(gamepad);
|
return c.SDL_GetGamepadProductVersion(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadFirmwareVersion(gamepad: *Gamepad) u16 {
|
pub inline fn getGamepadFirmwareVersion(gamepad: *Gamepad) u16 {
|
||||||
return c.SDL_GetGamepadFirmwareVersion(gamepad);
|
return c.SDL_GetGamepadFirmwareVersion(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadSerial(gamepad: *Gamepad) [*c]const u8 {
|
pub inline fn getGamepadSerial(gamepad: *Gamepad) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadSerial(gamepad);
|
return c.SDL_GetGamepadSerial(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadSteamHandle(gamepad: *Gamepad) u64 {
|
pub inline fn getGamepadSteamHandle(gamepad: *Gamepad) u64 {
|
||||||
return c.SDL_GetGamepadSteamHandle(gamepad);
|
return c.SDL_GetGamepadSteamHandle(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadConnectionState(gamepad: *Gamepad) JoystickConnectionState {
|
pub inline fn getGamepadConnectionState(gamepad: *Gamepad) JoystickConnectionState {
|
||||||
return c.SDL_GetGamepadConnectionState(gamepad);
|
return c.SDL_GetGamepadConnectionState(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadPowerInfo(gamepad: *Gamepad, percent: *c_int) PowerState {
|
pub inline fn getGamepadPowerInfo(gamepad: *Gamepad, percent: *c_int) PowerState {
|
||||||
return c.SDL_GetGamepadPowerInfo(gamepad, @ptrCast(percent));
|
return c.SDL_GetGamepadPowerInfo(@ptrCast(gamepad), @ptrCast(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadConnected(gamepad: *Gamepad) bool {
|
pub inline fn gamepadConnected(gamepad: *Gamepad) bool {
|
||||||
return c.SDL_GamepadConnected(gamepad);
|
return @bitCast(c.SDL_GamepadConnected(@ptrCast(gamepad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadJoystick(gamepad: *Gamepad) ?*Joystick {
|
pub inline fn getGamepadJoystick(gamepad: *Gamepad) ?*Joystick {
|
||||||
return c.SDL_GetGamepadJoystick(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][*c]GamepadBinding {
|
||||||
return c.SDL_GetGamepadBindings(gamepad, @ptrCast(count));
|
return c.SDL_GetGamepadBindings(@ptrCast(gamepad), @ptrCast(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadHasAxis(gamepad: *Gamepad, axis: GamepadAxis) bool {
|
pub inline fn gamepadHasAxis(gamepad: *Gamepad, axis: GamepadAxis) bool {
|
||||||
return c.SDL_GamepadHasAxis(gamepad, axis);
|
return @bitCast(c.SDL_GamepadHasAxis(@ptrCast(gamepad), axis));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadAxis(gamepad: *Gamepad, axis: GamepadAxis) i16 {
|
pub inline fn getGamepadAxis(gamepad: *Gamepad, axis: GamepadAxis) i16 {
|
||||||
return c.SDL_GetGamepadAxis(gamepad, axis);
|
return c.SDL_GetGamepadAxis(@ptrCast(gamepad), axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadHasButton(gamepad: *Gamepad, button: GamepadButton) bool {
|
pub inline fn gamepadHasButton(gamepad: *Gamepad, button: GamepadButton) bool {
|
||||||
return c.SDL_GamepadHasButton(gamepad, button);
|
return @bitCast(c.SDL_GamepadHasButton(@ptrCast(gamepad), button));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadButton(gamepad: *Gamepad, button: GamepadButton) bool {
|
pub inline fn getGamepadButton(gamepad: *Gamepad, button: GamepadButton) bool {
|
||||||
return c.SDL_GetGamepadButton(gamepad, button);
|
return @bitCast(c.SDL_GetGamepadButton(@ptrCast(gamepad), button));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadButtonLabel(gamepad: *Gamepad, button: GamepadButton) GamepadButtonLabel {
|
pub inline fn getGamepadButtonLabel(gamepad: *Gamepad, button: GamepadButton) GamepadButtonLabel {
|
||||||
return c.SDL_GetGamepadButtonLabel(gamepad, button);
|
return c.SDL_GetGamepadButtonLabel(@ptrCast(gamepad), button);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumGamepadTouchpads(gamepad: *Gamepad) c_int {
|
pub inline fn getNumGamepadTouchpads(gamepad: *Gamepad) c_int {
|
||||||
return c.SDL_GetNumGamepadTouchpads(gamepad);
|
return c.SDL_GetNumGamepadTouchpads(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumGamepadTouchpadFingers(gamepad: *Gamepad, touchpad: c_int) c_int {
|
pub inline fn getNumGamepadTouchpadFingers(gamepad: *Gamepad, touchpad: c_int) c_int {
|
||||||
return c.SDL_GetNumGamepadTouchpadFingers(gamepad, touchpad);
|
return c.SDL_GetNumGamepadTouchpadFingers(@ptrCast(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));
|
return @bitCast(c.SDL_GetGamepadTouchpadFinger(@ptrCast(gamepad), touchpad, finger, @ptrCast(down), @ptrCast(x), @ptrCast(y), @ptrCast(pressure)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadHasSensor(gamepad: *Gamepad, _type: SensorType) bool {
|
pub inline fn gamepadHasSensor(gamepad: *Gamepad, _type: SensorType) bool {
|
||||||
return c.SDL_GamepadHasSensor(gamepad, @intFromEnum(_type));
|
return @bitCast(c.SDL_GamepadHasSensor(@ptrCast(gamepad), @intFromEnum(_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadSensorEnabled(gamepad: *Gamepad, _type: SensorType, enabled: bool) bool {
|
pub inline fn setGamepadSensorEnabled(gamepad: *Gamepad, _type: SensorType, enabled: bool) bool {
|
||||||
return c.SDL_SetGamepadSensorEnabled(gamepad, @intFromEnum(_type), enabled);
|
return @bitCast(c.SDL_SetGamepadSensorEnabled(@ptrCast(gamepad), @intFromEnum(_type), @bitCast(enabled)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadSensorEnabled(gamepad: *Gamepad, _type: SensorType) bool {
|
pub inline fn gamepadSensorEnabled(gamepad: *Gamepad, _type: SensorType) bool {
|
||||||
return c.SDL_GamepadSensorEnabled(gamepad, @intFromEnum(_type));
|
return @bitCast(c.SDL_GamepadSensorEnabled(@ptrCast(gamepad), @intFromEnum(_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadSensorDataRate(gamepad: *Gamepad, _type: SensorType) f32 {
|
pub inline fn getGamepadSensorDataRate(gamepad: *Gamepad, _type: SensorType) f32 {
|
||||||
return c.SDL_GetGamepadSensorDataRate(gamepad, @intFromEnum(_type));
|
return c.SDL_GetGamepadSensorDataRate(@ptrCast(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);
|
return @bitCast(c.SDL_GetGamepadSensorData(@ptrCast(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);
|
return @bitCast(c.SDL_RumbleGamepad(@ptrCast(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);
|
return @bitCast(c.SDL_RumbleGamepadTriggers(@ptrCast(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);
|
return @bitCast(c.SDL_SetGamepadLED(@ptrCast(gamepad), red, green, blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn sendGamepadEffect(gamepad: *Gamepad, data: ?*const anyopaque, size: c_int) bool {
|
pub inline fn sendGamepadEffect(gamepad: *Gamepad, data: ?*const anyopaque, size: c_int) bool {
|
||||||
return c.SDL_SendGamepadEffect(gamepad, data, size);
|
return @bitCast(c.SDL_SendGamepadEffect(@ptrCast(gamepad), data, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeGamepad(gamepad: *Gamepad) void {
|
pub inline fn closeGamepad(gamepad: *Gamepad) void {
|
||||||
return c.SDL_CloseGamepad(gamepad);
|
return c.SDL_CloseGamepad(@ptrCast(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadAppleSFSymbolsNameForButton(gamepad: *Gamepad, button: GamepadButton) [*c]const u8 {
|
pub inline fn getGamepadAppleSFSymbolsNameForButton(gamepad: *Gamepad, button: GamepadButton) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadAppleSFSymbolsNameForButton(gamepad, button);
|
return c.SDL_GetGamepadAppleSFSymbolsNameForButton(@ptrCast(gamepad), button);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadAppleSFSymbolsNameForAxis(gamepad: *Gamepad, axis: GamepadAxis) [*c]const u8 {
|
pub inline fn getGamepadAppleSFSymbolsNameForAxis(gamepad: *Gamepad, axis: GamepadAxis) [*c]const u8 {
|
||||||
return c.SDL_GetGamepadAppleSFSymbolsNameForAxis(gamepad, axis);
|
return c.SDL_GetGamepadAppleSFSymbolsNameForAxis(@ptrCast(gamepad), axis);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -217,6 +217,7 @@ pub const GamepadType = enum(c_int) {
|
||||||
gamepadTypeNintendoSwitchJoyconLeft,
|
gamepadTypeNintendoSwitchJoyconLeft,
|
||||||
gamepadTypeNintendoSwitchJoyconRight,
|
gamepadTypeNintendoSwitchJoyconRight,
|
||||||
gamepadTypeNintendoSwitchJoyconPair,
|
gamepadTypeNintendoSwitchJoyconPair,
|
||||||
|
gamepadTypeGamecube,
|
||||||
gamepadTypeCount,
|
gamepadTypeCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -237,14 +238,14 @@ pub const GamepadButton = enum(c_int) {
|
||||||
gamepadButtonDpadLeft,
|
gamepadButtonDpadLeft,
|
||||||
gamepadButtonDpadRight,
|
gamepadButtonDpadRight,
|
||||||
gamepadButtonMisc1, //Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button)
|
gamepadButtonMisc1, //Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button)
|
||||||
gamepadButtonRightPaddle1, //Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1)
|
gamepadButtonRightPaddle1, //Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button)
|
||||||
gamepadButtonLeftPaddle1, //Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3)
|
gamepadButtonLeftPaddle1, //Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button)
|
||||||
gamepadButtonRightPaddle2, //Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2)
|
gamepadButtonRightPaddle2, //Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button)
|
||||||
gamepadButtonLeftPaddle2, //Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4)
|
gamepadButtonLeftPaddle2, //Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button)
|
||||||
gamepadButtonTouchpad, //PS4/PS5 touchpad button
|
gamepadButtonTouchpad, //PS4/PS5 touchpad button
|
||||||
gamepadButtonMisc2, //Additional button
|
gamepadButtonMisc2, //Additional button
|
||||||
gamepadButtonMisc3, //Additional button
|
gamepadButtonMisc3, //Additional button (e.g. Nintendo GameCube left trigger click)
|
||||||
gamepadButtonMisc4, //Additional button
|
gamepadButtonMisc4, //Additional button (e.g. Nintendo GameCube right trigger click)
|
||||||
gamepadButtonMisc5, //Additional button
|
gamepadButtonMisc5, //Additional button
|
||||||
gamepadButtonMisc6, //Additional button
|
gamepadButtonMisc6, //Additional button
|
||||||
gamepadButtonCount,
|
gamepadButtonCount,
|
||||||
|
|
@ -289,7 +290,7 @@ pub inline fn addGamepadMappingsFromFile(file: [*c]const u8) c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn reloadGamepadMappings() bool {
|
pub inline fn reloadGamepadMappings() bool {
|
||||||
return c.SDL_ReloadGamepadMappings();
|
return @bitCast(c.SDL_ReloadGamepadMappings());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadMappings(count: *c_int) [*c][*c]u8 {
|
pub inline fn getGamepadMappings(count: *c_int) [*c][*c]u8 {
|
||||||
|
|
@ -301,19 +302,19 @@ pub inline fn getGamepadMappingForGUID(guid: GUID) [*c]u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadMapping(instance_id: JoystickID, mapping: [*c]const u8) bool {
|
pub inline fn setGamepadMapping(instance_id: JoystickID, mapping: [*c]const u8) bool {
|
||||||
return c.SDL_SetGamepadMapping(instance_id, mapping);
|
return @bitCast(c.SDL_SetGamepadMapping(instance_id, mapping));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasGamepad() bool {
|
pub inline fn hasGamepad() bool {
|
||||||
return c.SDL_HasGamepad();
|
return @bitCast(c.SDL_HasGamepad());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepads(count: *c_int) ?*JoystickID {
|
pub inline fn getGamepads(count: *c_int) ?*JoystickID {
|
||||||
return c.SDL_GetGamepads(@ptrCast(count));
|
return @ptrCast(c.SDL_GetGamepads(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isGamepad(instance_id: JoystickID) bool {
|
pub inline fn isGamepad(instance_id: JoystickID) bool {
|
||||||
return c.SDL_IsGamepad(instance_id);
|
return @bitCast(c.SDL_IsGamepad(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadNameForID(instance_id: JoystickID) [*c]const u8 {
|
pub inline fn getGamepadNameForID(instance_id: JoystickID) [*c]const u8 {
|
||||||
|
|
@ -357,23 +358,23 @@ pub inline fn getGamepadMappingForID(instance_id: JoystickID) [*c]u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openGamepad(instance_id: JoystickID) ?*Gamepad {
|
pub inline fn openGamepad(instance_id: JoystickID) ?*Gamepad {
|
||||||
return c.SDL_OpenGamepad(instance_id);
|
return @ptrCast(c.SDL_OpenGamepad(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadFromID(instance_id: JoystickID) ?*Gamepad {
|
pub inline fn getGamepadFromID(instance_id: JoystickID) ?*Gamepad {
|
||||||
return c.SDL_GetGamepadFromID(instance_id);
|
return @ptrCast(c.SDL_GetGamepadFromID(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGamepadFromPlayerIndex(player_index: c_int) ?*Gamepad {
|
pub inline fn getGamepadFromPlayerIndex(player_index: c_int) ?*Gamepad {
|
||||||
return c.SDL_GetGamepadFromPlayerIndex(player_index);
|
return @ptrCast(c.SDL_GetGamepadFromPlayerIndex(player_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGamepadEventsEnabled(enabled: bool) void {
|
pub inline fn setGamepadEventsEnabled(enabled: bool) void {
|
||||||
return c.SDL_SetGamepadEventsEnabled(enabled);
|
return c.SDL_SetGamepadEventsEnabled(@bitCast(enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gamepadEventsEnabled() bool {
|
pub inline fn gamepadEventsEnabled() bool {
|
||||||
return c.SDL_GamepadEventsEnabled();
|
return @bitCast(c.SDL_GamepadEventsEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateGamepads() void {
|
pub inline fn updateGamepads() void {
|
||||||
|
|
|
||||||
238
api/gpu.zig
238
api/gpu.zig
|
|
@ -10,6 +10,19 @@ pub const FColor = extern struct {
|
||||||
|
|
||||||
pub const PropertiesID = u32;
|
pub const PropertiesID = u32;
|
||||||
|
|
||||||
|
pub const PixelFormat = enum(c_int) {
|
||||||
|
pixelformatYv12 = 0x32315659, //Planar mode: Y + V + U (3 planes)
|
||||||
|
pixelformatIyuv = 0x56555949, //Planar mode: Y + U + V (3 planes)
|
||||||
|
pixelformatYuy2 = 0x32595559, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
||||||
|
pixelformatUyvy = 0x59565955, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
||||||
|
pixelformatYvyu = 0x55595659, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
||||||
|
pixelformatNv12 = 0x3231564e, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
|
pixelformatNv21 = 0x3132564e, //Planar mode: Y + V/U interleaved (2 planes)
|
||||||
|
pixelformatP010 = 0x30313050, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
|
pixelformatExternalOes = 0x2053454f, //Android video texture format
|
||||||
|
pixelformatMjpg = 0x47504a4d, //Motion JPEG
|
||||||
|
};
|
||||||
|
|
||||||
pub const Rect = extern struct {
|
pub const Rect = extern struct {
|
||||||
x: c_int,
|
x: c_int,
|
||||||
y: c_int,
|
y: c_int,
|
||||||
|
|
@ -19,163 +32,170 @@ pub const Rect = extern struct {
|
||||||
|
|
||||||
pub const Window = opaque {};
|
pub const Window = opaque {};
|
||||||
|
|
||||||
pub const FlipMode = enum(c_int) {
|
pub const FlipMode = packed struct(u32) {
|
||||||
flipNone, //Do not flip
|
flipHorizontal: bool = false, // flip horizontally
|
||||||
flipHorizontal, //flip horizontally
|
flipVertical: bool = false, // flip vertically
|
||||||
flipVertical, //flip vertically
|
pad0: u29 = 0,
|
||||||
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = FlipMode{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUDevice = opaque {
|
pub const GPUDevice = opaque {
|
||||||
pub inline fn destroyGPUDevice(gpudevice: *GPUDevice) void {
|
pub inline fn destroyGPUDevice(gpudevice: *GPUDevice) void {
|
||||||
return c.SDL_DestroyGPUDevice(gpudevice);
|
return c.SDL_DestroyGPUDevice(@ptrCast(gpudevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGPUDeviceDriver(gpudevice: *GPUDevice) [*c]const u8 {
|
pub inline fn getGPUDeviceDriver(gpudevice: *GPUDevice) [*c]const u8 {
|
||||||
return c.SDL_GetGPUDeviceDriver(gpudevice);
|
return c.SDL_GetGPUDeviceDriver(@ptrCast(gpudevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGPUShaderFormats(gpudevice: *GPUDevice) GPUShaderFormat {
|
pub inline fn getGPUShaderFormats(gpudevice: *GPUDevice) GPUShaderFormat {
|
||||||
return @bitCast(c.SDL_GetGPUShaderFormats(gpudevice));
|
return @bitCast(c.SDL_GetGPUShaderFormats(@ptrCast(gpudevice)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getGPUDeviceProperties(gpudevice: *GPUDevice) PropertiesID {
|
||||||
|
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 c.SDL_CreateGPUComputePipeline(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 c.SDL_CreateGPUGraphicsPipeline(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 c.SDL_CreateGPUSampler(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 c.SDL_CreateGPUShader(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 c.SDL_CreateGPUTexture(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 c.SDL_CreateGPUBuffer(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 c.SDL_CreateGPUTransferBuffer(gpudevice, @ptrCast(createinfo));
|
return @ptrCast(c.SDL_CreateGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(createinfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUBufferName(gpudevice: *GPUDevice, buffer: ?*GPUBuffer, text: [*c]const u8) void {
|
pub inline fn setGPUBufferName(gpudevice: *GPUDevice, buffer: ?*GPUBuffer, text: [*c]const u8) void {
|
||||||
return c.SDL_SetGPUBufferName(gpudevice, buffer, text);
|
return c.SDL_SetGPUBufferName(@ptrCast(gpudevice), @ptrCast(buffer), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUTextureName(gpudevice: *GPUDevice, texture: ?*GPUTexture, text: [*c]const u8) void {
|
pub inline fn setGPUTextureName(gpudevice: *GPUDevice, texture: ?*GPUTexture, text: [*c]const u8) void {
|
||||||
return c.SDL_SetGPUTextureName(gpudevice, texture, text);
|
return c.SDL_SetGPUTextureName(@ptrCast(gpudevice), @ptrCast(texture), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUTexture(gpudevice: *GPUDevice, texture: ?*GPUTexture) void {
|
pub inline fn releaseGPUTexture(gpudevice: *GPUDevice, texture: ?*GPUTexture) void {
|
||||||
return c.SDL_ReleaseGPUTexture(gpudevice, texture);
|
return c.SDL_ReleaseGPUTexture(@ptrCast(gpudevice), @ptrCast(texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUSampler(gpudevice: *GPUDevice, sampler: ?*GPUSampler) void {
|
pub inline fn releaseGPUSampler(gpudevice: *GPUDevice, sampler: ?*GPUSampler) void {
|
||||||
return c.SDL_ReleaseGPUSampler(gpudevice, sampler);
|
return c.SDL_ReleaseGPUSampler(@ptrCast(gpudevice), @ptrCast(sampler));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUBuffer(gpudevice: *GPUDevice, buffer: ?*GPUBuffer) void {
|
pub inline fn releaseGPUBuffer(gpudevice: *GPUDevice, buffer: ?*GPUBuffer) void {
|
||||||
return c.SDL_ReleaseGPUBuffer(gpudevice, buffer);
|
return c.SDL_ReleaseGPUBuffer(@ptrCast(gpudevice), @ptrCast(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer) void {
|
pub inline fn releaseGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer) void {
|
||||||
return c.SDL_ReleaseGPUTransferBuffer(gpudevice, transfer_buffer);
|
return c.SDL_ReleaseGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(transfer_buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUComputePipeline(gpudevice: *GPUDevice, compute_pipeline: ?*GPUComputePipeline) void {
|
pub inline fn releaseGPUComputePipeline(gpudevice: *GPUDevice, compute_pipeline: ?*GPUComputePipeline) void {
|
||||||
return c.SDL_ReleaseGPUComputePipeline(gpudevice, compute_pipeline);
|
return c.SDL_ReleaseGPUComputePipeline(@ptrCast(gpudevice), @ptrCast(compute_pipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUShader(gpudevice: *GPUDevice, shader: ?*GPUShader) void {
|
pub inline fn releaseGPUShader(gpudevice: *GPUDevice, shader: ?*GPUShader) void {
|
||||||
return c.SDL_ReleaseGPUShader(gpudevice, shader);
|
return c.SDL_ReleaseGPUShader(@ptrCast(gpudevice), @ptrCast(shader));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUGraphicsPipeline(gpudevice: *GPUDevice, graphics_pipeline: ?*GPUGraphicsPipeline) void {
|
pub inline fn releaseGPUGraphicsPipeline(gpudevice: *GPUDevice, graphics_pipeline: ?*GPUGraphicsPipeline) void {
|
||||||
return c.SDL_ReleaseGPUGraphicsPipeline(gpudevice, graphics_pipeline);
|
return c.SDL_ReleaseGPUGraphicsPipeline(@ptrCast(gpudevice), @ptrCast(graphics_pipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn acquireGPUCommandBuffer(gpudevice: *GPUDevice) ?*GPUCommandBuffer {
|
pub inline fn acquireGPUCommandBuffer(gpudevice: *GPUDevice) ?*GPUCommandBuffer {
|
||||||
return c.SDL_AcquireGPUCommandBuffer(gpudevice);
|
return @ptrCast(c.SDL_AcquireGPUCommandBuffer(@ptrCast(gpudevice)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn mapGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer, cycle: bool) ?*anyopaque {
|
pub inline fn mapGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer, cycle: bool) ?*anyopaque {
|
||||||
return c.SDL_MapGPUTransferBuffer(gpudevice, transfer_buffer, cycle);
|
return c.SDL_MapGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(transfer_buffer), @bitCast(cycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unmapGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer) void {
|
pub inline fn unmapGPUTransferBuffer(gpudevice: *GPUDevice, transfer_buffer: ?*GPUTransferBuffer) void {
|
||||||
return c.SDL_UnmapGPUTransferBuffer(gpudevice, transfer_buffer);
|
return c.SDL_UnmapGPUTransferBuffer(@ptrCast(gpudevice), @ptrCast(transfer_buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn windowSupportsGPUSwapchainComposition(gpudevice: *GPUDevice, window: ?*Window, swapchain_composition: GPUSwapchainComposition) bool {
|
pub inline fn windowSupportsGPUSwapchainComposition(gpudevice: *GPUDevice, window: ?*Window, swapchain_composition: GPUSwapchainComposition) bool {
|
||||||
return c.SDL_WindowSupportsGPUSwapchainComposition(gpudevice, window, swapchain_composition);
|
return @bitCast(c.SDL_WindowSupportsGPUSwapchainComposition(@ptrCast(gpudevice), @ptrCast(window), swapchain_composition));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn windowSupportsGPUPresentMode(gpudevice: *GPUDevice, window: ?*Window, present_mode: GPUPresentMode) bool {
|
pub inline fn windowSupportsGPUPresentMode(gpudevice: *GPUDevice, window: ?*Window, present_mode: GPUPresentMode) bool {
|
||||||
return c.SDL_WindowSupportsGPUPresentMode(gpudevice, window, @intFromEnum(present_mode));
|
return @bitCast(c.SDL_WindowSupportsGPUPresentMode(@ptrCast(gpudevice), @ptrCast(window), @intFromEnum(present_mode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn claimWindowForGPUDevice(gpudevice: *GPUDevice, window: ?*Window) bool {
|
pub inline fn claimWindowForGPUDevice(gpudevice: *GPUDevice, window: ?*Window) bool {
|
||||||
return c.SDL_ClaimWindowForGPUDevice(gpudevice, window);
|
return @bitCast(c.SDL_ClaimWindowForGPUDevice(@ptrCast(gpudevice), @ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseWindowFromGPUDevice(gpudevice: *GPUDevice, window: ?*Window) void {
|
pub inline fn releaseWindowFromGPUDevice(gpudevice: *GPUDevice, window: ?*Window) void {
|
||||||
return c.SDL_ReleaseWindowFromGPUDevice(gpudevice, window);
|
return c.SDL_ReleaseWindowFromGPUDevice(@ptrCast(gpudevice), @ptrCast(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));
|
return @bitCast(c.SDL_SetGPUSwapchainParameters(@ptrCast(gpudevice), @ptrCast(window), swapchain_composition, @intFromEnum(present_mode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUAllowedFramesInFlight(gpudevice: *GPUDevice, allowed_frames_in_flight: u32) bool {
|
pub inline fn setGPUAllowedFramesInFlight(gpudevice: *GPUDevice, allowed_frames_in_flight: u32) bool {
|
||||||
return c.SDL_SetGPUAllowedFramesInFlight(gpudevice, allowed_frames_in_flight);
|
return @bitCast(c.SDL_SetGPUAllowedFramesInFlight(@ptrCast(gpudevice), allowed_frames_in_flight));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGPUSwapchainTextureFormat(gpudevice: *GPUDevice, window: ?*Window) GPUTextureFormat {
|
pub inline fn getGPUSwapchainTextureFormat(gpudevice: *GPUDevice, window: ?*Window) GPUTextureFormat {
|
||||||
return @bitCast(c.SDL_GetGPUSwapchainTextureFormat(gpudevice, window));
|
return @bitCast(c.SDL_GetGPUSwapchainTextureFormat(@ptrCast(gpudevice), @ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitForGPUSwapchain(gpudevice: *GPUDevice, window: ?*Window) bool {
|
pub inline fn waitForGPUSwapchain(gpudevice: *GPUDevice, window: ?*Window) bool {
|
||||||
return c.SDL_WaitForGPUSwapchain(gpudevice, window);
|
return @bitCast(c.SDL_WaitForGPUSwapchain(@ptrCast(gpudevice), @ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn waitForGPUIdle(gpudevice: *GPUDevice) bool {
|
pub inline fn waitForGPUIdle(gpudevice: *GPUDevice) bool {
|
||||||
return c.SDL_WaitForGPUIdle(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 c.SDL_WaitForGPUFences(gpudevice, wait_all, fences, num_fences);
|
return @bitCast(c.SDL_WaitForGPUFences(@ptrCast(gpudevice), @bitCast(wait_all), fences, num_fences));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn queryGPUFence(gpudevice: *GPUDevice, fence: ?*GPUFence) bool {
|
pub inline fn queryGPUFence(gpudevice: *GPUDevice, fence: ?*GPUFence) bool {
|
||||||
return c.SDL_QueryGPUFence(gpudevice, fence);
|
return @bitCast(c.SDL_QueryGPUFence(@ptrCast(gpudevice), @ptrCast(fence)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn releaseGPUFence(gpudevice: *GPUDevice, fence: ?*GPUFence) void {
|
pub inline fn releaseGPUFence(gpudevice: *GPUDevice, fence: ?*GPUFence) void {
|
||||||
return c.SDL_ReleaseGPUFence(gpudevice, fence);
|
return c.SDL_ReleaseGPUFence(@ptrCast(gpudevice), @ptrCast(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));
|
return @bitCast(c.SDL_GPUTextureSupportsFormat(@ptrCast(gpudevice), @bitCast(format), @intFromEnum(_type), @bitCast(usage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gpuTextureSupportsSampleCount(gpudevice: *GPUDevice, format: GPUTextureFormat, sample_count: GPUSampleCount) bool {
|
pub inline fn gpuTextureSupportsSampleCount(gpudevice: *GPUDevice, format: GPUTextureFormat, sample_count: GPUSampleCount) bool {
|
||||||
return c.SDL_GPUTextureSupportsSampleCount(gpudevice, @bitCast(format), sample_count);
|
return @bitCast(c.SDL_GPUTextureSupportsSampleCount(@ptrCast(gpudevice), @bitCast(format), sample_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gdkSuspendGPU(gpudevice: *GPUDevice) void {
|
pub inline fn gdkSuspendGPU(gpudevice: *GPUDevice) void {
|
||||||
return c.SDL_GDKSuspendGPU(gpudevice);
|
return c.SDL_GDKSuspendGPU(@ptrCast(gpudevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gdkResumeGPU(gpudevice: *GPUDevice) void {
|
pub inline fn gdkResumeGPU(gpudevice: *GPUDevice) void {
|
||||||
return c.SDL_GDKResumeGPU(gpudevice);
|
return c.SDL_GDKResumeGPU(@ptrCast(gpudevice));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -195,201 +215,201 @@ pub const GPUGraphicsPipeline = opaque {};
|
||||||
|
|
||||||
pub const GPUCommandBuffer = opaque {
|
pub const GPUCommandBuffer = opaque {
|
||||||
pub inline fn insertGPUDebugLabel(gpucommandbuffer: *GPUCommandBuffer, text: [*c]const u8) void {
|
pub inline fn insertGPUDebugLabel(gpucommandbuffer: *GPUCommandBuffer, text: [*c]const u8) void {
|
||||||
return c.SDL_InsertGPUDebugLabel(gpucommandbuffer, text);
|
return c.SDL_InsertGPUDebugLabel(@ptrCast(gpucommandbuffer), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pushGPUDebugGroup(gpucommandbuffer: *GPUCommandBuffer, name: [*c]const u8) void {
|
pub inline fn pushGPUDebugGroup(gpucommandbuffer: *GPUCommandBuffer, name: [*c]const u8) void {
|
||||||
return c.SDL_PushGPUDebugGroup(gpucommandbuffer, name);
|
return c.SDL_PushGPUDebugGroup(@ptrCast(gpucommandbuffer), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn popGPUDebugGroup(gpucommandbuffer: *GPUCommandBuffer) void {
|
pub inline fn popGPUDebugGroup(gpucommandbuffer: *GPUCommandBuffer) void {
|
||||||
return c.SDL_PopGPUDebugGroup(gpucommandbuffer);
|
return c.SDL_PopGPUDebugGroup(@ptrCast(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);
|
return c.SDL_PushGPUVertexUniformData(@ptrCast(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);
|
return c.SDL_PushGPUFragmentUniformData(@ptrCast(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);
|
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 c.SDL_BeginGPURenderPass(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 c.SDL_BeginGPUComputePass(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));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn beginGPUCopyPass(gpucommandbuffer: *GPUCommandBuffer) ?*GPUCopyPass {
|
pub inline fn beginGPUCopyPass(gpucommandbuffer: *GPUCommandBuffer) ?*GPUCopyPass {
|
||||||
return c.SDL_BeginGPUCopyPass(gpucommandbuffer);
|
return @ptrCast(c.SDL_BeginGPUCopyPass(@ptrCast(gpucommandbuffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn generateMipmapsForGPUTexture(gpucommandbuffer: *GPUCommandBuffer, texture: ?*GPUTexture) void {
|
pub inline fn generateMipmapsForGPUTexture(gpucommandbuffer: *GPUCommandBuffer, texture: ?*GPUTexture) void {
|
||||||
return c.SDL_GenerateMipmapsForGPUTexture(gpucommandbuffer, 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(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][*c]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));
|
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][*c]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));
|
return @bitCast(c.SDL_WaitAndAcquireGPUSwapchainTexture(@ptrCast(gpucommandbuffer), @ptrCast(window), swapchain_texture, @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn submitGPUCommandBuffer(gpucommandbuffer: *GPUCommandBuffer) bool {
|
pub inline fn submitGPUCommandBuffer(gpucommandbuffer: *GPUCommandBuffer) bool {
|
||||||
return c.SDL_SubmitGPUCommandBuffer(gpucommandbuffer);
|
return @bitCast(c.SDL_SubmitGPUCommandBuffer(@ptrCast(gpucommandbuffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn submitGPUCommandBufferAndAcquireFence(gpucommandbuffer: *GPUCommandBuffer) ?*GPUFence {
|
pub inline fn submitGPUCommandBufferAndAcquireFence(gpucommandbuffer: *GPUCommandBuffer) ?*GPUFence {
|
||||||
return c.SDL_SubmitGPUCommandBufferAndAcquireFence(gpucommandbuffer);
|
return @ptrCast(c.SDL_SubmitGPUCommandBufferAndAcquireFence(@ptrCast(gpucommandbuffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn cancelGPUCommandBuffer(gpucommandbuffer: *GPUCommandBuffer) bool {
|
pub inline fn cancelGPUCommandBuffer(gpucommandbuffer: *GPUCommandBuffer) bool {
|
||||||
return c.SDL_CancelGPUCommandBuffer(gpucommandbuffer);
|
return @bitCast(c.SDL_CancelGPUCommandBuffer(@ptrCast(gpucommandbuffer)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPURenderPass = opaque {
|
pub const GPURenderPass = opaque {
|
||||||
pub inline fn bindGPUGraphicsPipeline(gpurenderpass: *GPURenderPass, graphics_pipeline: ?*GPUGraphicsPipeline) void {
|
pub inline fn bindGPUGraphicsPipeline(gpurenderpass: *GPURenderPass, graphics_pipeline: ?*GPUGraphicsPipeline) void {
|
||||||
return c.SDL_BindGPUGraphicsPipeline(gpurenderpass, 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(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(gpurenderpass, @ptrCast(scissor));
|
return c.SDL_SetGPUScissor(@ptrCast(gpurenderpass), @ptrCast(scissor));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUBlendConstants(gpurenderpass: *GPURenderPass, blend_constants: FColor) void {
|
pub inline fn setGPUBlendConstants(gpurenderpass: *GPURenderPass, blend_constants: FColor) void {
|
||||||
return c.SDL_SetGPUBlendConstants(gpurenderpass, blend_constants);
|
return c.SDL_SetGPUBlendConstants(@ptrCast(gpurenderpass), blend_constants);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setGPUStencilReference(gpurenderpass: *GPURenderPass, reference: u8) void {
|
pub inline fn setGPUStencilReference(gpurenderpass: *GPURenderPass, reference: u8) void {
|
||||||
return c.SDL_SetGPUStencilReference(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(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(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(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(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(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(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(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(gpurenderpass, first_slot, storage_buffers, num_bindings);
|
return c.SDL_BindGPUFragmentStorageBuffers(@ptrCast(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);
|
return c.SDL_DrawGPUIndexedPrimitives(@ptrCast(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);
|
return c.SDL_DrawGPUPrimitives(@ptrCast(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);
|
return c.SDL_DrawGPUPrimitivesIndirect(@ptrCast(gpurenderpass), @ptrCast(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);
|
return c.SDL_DrawGPUIndexedPrimitivesIndirect(@ptrCast(gpurenderpass), @ptrCast(buffer), offset, draw_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn endGPURenderPass(gpurenderpass: *GPURenderPass) void {
|
pub inline fn endGPURenderPass(gpurenderpass: *GPURenderPass) void {
|
||||||
return c.SDL_EndGPURenderPass(gpurenderpass);
|
return c.SDL_EndGPURenderPass(@ptrCast(gpurenderpass));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUComputePass = opaque {
|
pub const GPUComputePass = opaque {
|
||||||
pub inline fn bindGPUComputePipeline(gpucomputepass: *GPUComputePass, compute_pipeline: ?*GPUComputePipeline) void {
|
pub inline fn bindGPUComputePipeline(gpucomputepass: *GPUComputePass, compute_pipeline: ?*GPUComputePipeline) void {
|
||||||
return c.SDL_BindGPUComputePipeline(gpucomputepass, 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(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(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(gpucomputepass, first_slot, storage_buffers, num_bindings);
|
return c.SDL_BindGPUComputeStorageBuffers(@ptrCast(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);
|
return c.SDL_DispatchGPUCompute(@ptrCast(gpucomputepass), groupcount_x, groupcount_y, groupcount_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn dispatchGPUComputeIndirect(gpucomputepass: *GPUComputePass, buffer: ?*GPUBuffer, offset: u32) void {
|
pub inline fn dispatchGPUComputeIndirect(gpucomputepass: *GPUComputePass, buffer: ?*GPUBuffer, offset: u32) void {
|
||||||
return c.SDL_DispatchGPUComputeIndirect(gpucomputepass, buffer, offset);
|
return c.SDL_DispatchGPUComputeIndirect(@ptrCast(gpucomputepass), @ptrCast(buffer), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn endGPUComputePass(gpucomputepass: *GPUComputePass) void {
|
pub inline fn endGPUComputePass(gpucomputepass: *GPUComputePass) void {
|
||||||
return c.SDL_EndGPUComputePass(gpucomputepass);
|
return c.SDL_EndGPUComputePass(@ptrCast(gpucomputepass));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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(gpucopypass, @ptrCast(source), @ptrCast(destination), 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(gpucopypass, @ptrCast(source), @ptrCast(destination), 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(gpucopypass, @ptrCast(source), @ptrCast(destination), w, h, d, 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(gpucopypass, @ptrCast(source), @ptrCast(destination), size, 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(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(gpucopypass, @ptrCast(source), @ptrCast(destination));
|
return c.SDL_DownloadFromGPUBuffer(@ptrCast(gpucopypass), @ptrCast(source), @ptrCast(destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn endGPUCopyPass(gpucopypass: *GPUCopyPass) void {
|
pub inline fn endGPUCopyPass(gpucopypass: *GPUCopyPass) void {
|
||||||
return c.SDL_EndGPUCopyPass(gpucopypass);
|
return c.SDL_EndGPUCopyPass(@ptrCast(gpucopypass));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -539,6 +559,8 @@ pub const GPUTextureUsageFlags = packed struct(u32) {
|
||||||
textureusageComputeStorageSimultaneousReadWrite: bool = false, // Texture supports reads and writes in the same compute shader. This is NOT equivalent to READ | WRITE.
|
textureusageComputeStorageSimultaneousReadWrite: bool = false, // Texture supports reads and writes in the same compute shader. This is NOT equivalent to READ | WRITE.
|
||||||
pad0: u24 = 0,
|
pad0: u24 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = GPUTextureUsageFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUTextureType = enum(c_int) {
|
pub const GPUTextureType = enum(c_int) {
|
||||||
|
|
@ -574,6 +596,8 @@ pub const GPUBufferUsageFlags = packed struct(u32) {
|
||||||
bufferusageComputeStorageWrite: bool = false, // Buffer supports storage writes in the compute stage.
|
bufferusageComputeStorageWrite: bool = false, // Buffer supports storage writes in the compute stage.
|
||||||
pad0: u25 = 0,
|
pad0: u25 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = GPUBufferUsageFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUTransferBufferUsage = enum(c_int) {
|
pub const GPUTransferBufferUsage = enum(c_int) {
|
||||||
|
|
@ -700,6 +724,8 @@ pub const GPUColorComponentFlags = packed struct(u8) {
|
||||||
colorcomponentA: bool = false, // the alpha component
|
colorcomponentA: bool = false, // the alpha component
|
||||||
pad0: u3 = 0,
|
pad0: u3 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = GPUColorComponentFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUFilter = enum(c_int) {
|
pub const GPUFilter = enum(c_int) {
|
||||||
|
|
@ -930,7 +956,7 @@ pub const GPUMultisampleState = extern struct {
|
||||||
sample_count: GPUSampleCount, // The number of samples to be used in rasterization.
|
sample_count: GPUSampleCount, // The number of samples to be used in rasterization.
|
||||||
sample_mask: u32, // Reserved for future use. Must be set to 0.
|
sample_mask: u32, // Reserved for future use. Must be set to 0.
|
||||||
enable_mask: bool, // Reserved for future use. Must be set to false.
|
enable_mask: bool, // Reserved for future use. Must be set to false.
|
||||||
padding1: u8,
|
enable_alpha_to_coverage: bool, // true enables the alpha-to-coverage feature.
|
||||||
padding2: u8,
|
padding2: u8,
|
||||||
padding3: u8,
|
padding3: u8,
|
||||||
};
|
};
|
||||||
|
|
@ -1018,8 +1044,8 @@ pub const GPUDepthStencilTargetInfo = extern struct {
|
||||||
stencil_store_op: GPUStoreOp, // What is done with the stencil results of the render pass.
|
stencil_store_op: GPUStoreOp, // What is done with the stencil results of the render pass.
|
||||||
cycle: bool, // true cycles the texture if the texture is bound and any load ops are not LOAD
|
cycle: bool, // true cycles the texture if the texture is bound and any load ops are not LOAD
|
||||||
clear_stencil: u8, // The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used.
|
clear_stencil: u8, // The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used.
|
||||||
padding1: u8,
|
mip_level: u8, // The mip level to use as the depth stencil target.
|
||||||
padding2: u8,
|
layer: u8, // The layer index to use as the depth stencil target.
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GPUBlitInfo = extern struct {
|
pub const GPUBlitInfo = extern struct {
|
||||||
|
|
@ -1064,21 +1090,31 @@ pub const GPUStorageTextureReadWriteBinding = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn gpuSupportsShaderFormats(format_flags: GPUShaderFormat, name: [*c]const u8) bool {
|
pub inline fn gpuSupportsShaderFormats(format_flags: GPUShaderFormat, name: [*c]const u8) bool {
|
||||||
return c.SDL_GPUSupportsShaderFormats(@bitCast(format_flags), name);
|
return @bitCast(c.SDL_GPUSupportsShaderFormats(@bitCast(format_flags), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gpuSupportsProperties(props: PropertiesID) bool {
|
pub inline fn gpuSupportsProperties(props: PropertiesID) bool {
|
||||||
return c.SDL_GPUSupportsProperties(props);
|
return @bitCast(c.SDL_GPUSupportsProperties(props));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUDevice(format_flags: GPUShaderFormat, debug_mode: bool, name: [*c]const u8) ?*GPUDevice {
|
pub inline fn createGPUDevice(format_flags: GPUShaderFormat, debug_mode: bool, name: [*c]const u8) ?*GPUDevice {
|
||||||
return c.SDL_CreateGPUDevice(@bitCast(format_flags), debug_mode, name);
|
return @ptrCast(c.SDL_CreateGPUDevice(@bitCast(format_flags), @bitCast(debug_mode), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createGPUDeviceWithProperties(props: PropertiesID) ?*GPUDevice {
|
pub inline fn createGPUDeviceWithProperties(props: PropertiesID) ?*GPUDevice {
|
||||||
return c.SDL_CreateGPUDeviceWithProperties(props);
|
return @ptrCast(c.SDL_CreateGPUDeviceWithProperties(props));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const GPUVulkanOptions = extern struct {
|
||||||
|
vulkan_api_version: u32, // The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION.
|
||||||
|
feature_list: ?*anyopaque, // Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)
|
||||||
|
vulkan_10_physical_device_features: ?*anyopaque, // Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features.
|
||||||
|
device_extension_count: u32, // Number of additional device extensions to require.
|
||||||
|
device_extension_names: [*c][*c]const u8, // Pointer to a list of additional device extensions to require.
|
||||||
|
instance_extension_count: u32, // Number of additional instance extensions to require.
|
||||||
|
instance_extension_names: [*c][*c]const u8, // Pointer to a list of additional instance extensions to require.
|
||||||
|
};
|
||||||
|
|
||||||
pub inline fn getNumGPUDrivers() c_int {
|
pub inline fn getNumGPUDrivers() c_int {
|
||||||
return c.SDL_GetNumGPUDrivers();
|
return c.SDL_GetNumGPUDrivers();
|
||||||
}
|
}
|
||||||
|
|
@ -1094,3 +1130,11 @@ pub inline fn gpuTextureFormatTexelBlockSize(format: GPUTextureFormat) u32 {
|
||||||
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);
|
return c.SDL_CalculateGPUTextureFormatSize(@bitCast(format), width, height, depth_or_layer_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub inline fn getPixelFormatFromGPUTextureFormat(format: GPUTextureFormat) PixelFormat {
|
||||||
|
return @bitCast(c.SDL_GetPixelFormatFromGPUTextureFormat(@bitCast(format)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getGPUTextureFormatFromPixelFormat(format: PixelFormat) GPUTextureFormat {
|
||||||
|
return @bitCast(c.SDL_GetGPUTextureFormatFromPixelFormat(@bitCast(format)));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,115 +3,121 @@ pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub const Joystick = opaque {
|
pub const Joystick = opaque {
|
||||||
pub inline fn isJoystickHaptic(joystick: *Joystick) bool {
|
pub inline fn isJoystickHaptic(joystick: *Joystick) bool {
|
||||||
return c.SDL_IsJoystickHaptic(joystick);
|
return @bitCast(c.SDL_IsJoystickHaptic(@ptrCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openHapticFromJoystick(joystick: *Joystick) ?*Haptic {
|
pub inline fn openHapticFromJoystick(joystick: *Joystick) ?*Haptic {
|
||||||
return c.SDL_OpenHapticFromJoystick(joystick);
|
return @ptrCast(c.SDL_OpenHapticFromJoystick(@ptrCast(joystick)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Haptic = opaque {
|
pub const Haptic = opaque {
|
||||||
pub inline fn getHapticID(haptic: *Haptic) HapticID {
|
pub inline fn getHapticID(haptic: *Haptic) HapticID {
|
||||||
return c.SDL_GetHapticID(haptic);
|
return c.SDL_GetHapticID(@ptrCast(haptic));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticName(haptic: *Haptic) [*c]const u8 {
|
pub inline fn getHapticName(haptic: *Haptic) [*c]const u8 {
|
||||||
return c.SDL_GetHapticName(haptic);
|
return c.SDL_GetHapticName(@ptrCast(haptic));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeHaptic(haptic: *Haptic) void {
|
pub inline fn closeHaptic(haptic: *Haptic) void {
|
||||||
return c.SDL_CloseHaptic(haptic);
|
return c.SDL_CloseHaptic(@ptrCast(haptic));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMaxHapticEffects(haptic: *Haptic) c_int {
|
pub inline fn getMaxHapticEffects(haptic: *Haptic) c_int {
|
||||||
return c.SDL_GetMaxHapticEffects(haptic);
|
return c.SDL_GetMaxHapticEffects(@ptrCast(haptic));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMaxHapticEffectsPlaying(haptic: *Haptic) c_int {
|
pub inline fn getMaxHapticEffectsPlaying(haptic: *Haptic) c_int {
|
||||||
return c.SDL_GetMaxHapticEffectsPlaying(haptic);
|
return c.SDL_GetMaxHapticEffectsPlaying(@ptrCast(haptic));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticFeatures(haptic: *Haptic) u32 {
|
pub inline fn getHapticFeatures(haptic: *Haptic) u32 {
|
||||||
return c.SDL_GetHapticFeatures(haptic);
|
return c.SDL_GetHapticFeatures(@ptrCast(haptic));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumHapticAxes(haptic: *Haptic) c_int {
|
pub inline fn getNumHapticAxes(haptic: *Haptic) c_int {
|
||||||
return c.SDL_GetNumHapticAxes(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 c.SDL_HapticEffectSupported(haptic, @ptrCast(effect));
|
return @bitCast(c.SDL_HapticEffectSupported(@ptrCast(haptic), @ptrCast(effect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createHapticEffect(haptic: *Haptic, effect: *const HapticEffect) c_int {
|
pub inline fn createHapticEffect(haptic: *Haptic, effect: *const HapticEffect) HapticEffectID {
|
||||||
return c.SDL_CreateHapticEffect(haptic, @ptrCast(effect));
|
return c.SDL_CreateHapticEffect(@ptrCast(haptic), @ptrCast(effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateHapticEffect(haptic: *Haptic, effect: c_int, data: *const HapticEffect) bool {
|
pub inline fn updateHapticEffect(haptic: *Haptic, effect: HapticEffectID, data: *const HapticEffect) bool {
|
||||||
return c.SDL_UpdateHapticEffect(haptic, effect, @ptrCast(data));
|
return @bitCast(c.SDL_UpdateHapticEffect(@ptrCast(haptic), effect, @ptrCast(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn runHapticEffect(haptic: *Haptic, effect: c_int, iterations: u32) bool {
|
pub inline fn runHapticEffect(haptic: *Haptic, effect: HapticEffectID, iterations: u32) bool {
|
||||||
return c.SDL_RunHapticEffect(haptic, effect, iterations);
|
return @bitCast(c.SDL_RunHapticEffect(@ptrCast(haptic), effect, iterations));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn stopHapticEffect(haptic: *Haptic, effect: c_int) bool {
|
pub inline fn stopHapticEffect(haptic: *Haptic, effect: HapticEffectID) bool {
|
||||||
return c.SDL_StopHapticEffect(haptic, effect);
|
return @bitCast(c.SDL_StopHapticEffect(@ptrCast(haptic), effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyHapticEffect(haptic: *Haptic, effect: c_int) void {
|
pub inline fn destroyHapticEffect(haptic: *Haptic, effect: HapticEffectID) void {
|
||||||
return c.SDL_DestroyHapticEffect(haptic, effect);
|
return c.SDL_DestroyHapticEffect(@ptrCast(haptic), effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticEffectStatus(haptic: *Haptic, effect: c_int) bool {
|
pub inline fn getHapticEffectStatus(haptic: *Haptic, effect: HapticEffectID) bool {
|
||||||
return c.SDL_GetHapticEffectStatus(haptic, effect);
|
return @bitCast(c.SDL_GetHapticEffectStatus(@ptrCast(haptic), effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setHapticGain(haptic: *Haptic, gain: c_int) bool {
|
pub inline fn setHapticGain(haptic: *Haptic, gain: c_int) bool {
|
||||||
return c.SDL_SetHapticGain(haptic, gain);
|
return @bitCast(c.SDL_SetHapticGain(@ptrCast(haptic), gain));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setHapticAutocenter(haptic: *Haptic, autocenter: c_int) bool {
|
pub inline fn setHapticAutocenter(haptic: *Haptic, autocenter: c_int) bool {
|
||||||
return c.SDL_SetHapticAutocenter(haptic, autocenter);
|
return @bitCast(c.SDL_SetHapticAutocenter(@ptrCast(haptic), autocenter));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pauseHaptic(haptic: *Haptic) bool {
|
pub inline fn pauseHaptic(haptic: *Haptic) bool {
|
||||||
return c.SDL_PauseHaptic(haptic);
|
return @bitCast(c.SDL_PauseHaptic(@ptrCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn resumeHaptic(haptic: *Haptic) bool {
|
pub inline fn resumeHaptic(haptic: *Haptic) bool {
|
||||||
return c.SDL_ResumeHaptic(haptic);
|
return @bitCast(c.SDL_ResumeHaptic(@ptrCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn stopHapticEffects(haptic: *Haptic) bool {
|
pub inline fn stopHapticEffects(haptic: *Haptic) bool {
|
||||||
return c.SDL_StopHapticEffects(haptic);
|
return @bitCast(c.SDL_StopHapticEffects(@ptrCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hapticRumbleSupported(haptic: *Haptic) bool {
|
pub inline fn hapticRumbleSupported(haptic: *Haptic) bool {
|
||||||
return c.SDL_HapticRumbleSupported(haptic);
|
return @bitCast(c.SDL_HapticRumbleSupported(@ptrCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn initHapticRumble(haptic: *Haptic) bool {
|
pub inline fn initHapticRumble(haptic: *Haptic) bool {
|
||||||
return c.SDL_InitHapticRumble(haptic);
|
return @bitCast(c.SDL_InitHapticRumble(@ptrCast(haptic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn playHapticRumble(haptic: *Haptic, strength: f32, length: u32) bool {
|
pub inline fn playHapticRumble(haptic: *Haptic, strength: f32, length: u32) bool {
|
||||||
return c.SDL_PlayHapticRumble(haptic, strength, length);
|
return @bitCast(c.SDL_PlayHapticRumble(@ptrCast(haptic), strength, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn stopHapticRumble(haptic: *Haptic) bool {
|
pub inline fn stopHapticRumble(haptic: *Haptic) bool {
|
||||||
return c.SDL_StopHapticRumble(haptic);
|
return @bitCast(c.SDL_StopHapticRumble(@ptrCast(haptic)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const HapticEffectType = u16;
|
||||||
|
|
||||||
|
pub const HapticDirectionType = u8;
|
||||||
|
|
||||||
|
pub const HapticEffectID = c_int;
|
||||||
|
|
||||||
pub const HapticDirection = extern struct {
|
pub const HapticDirection = extern struct {
|
||||||
_type: u8, // The type of encoding.
|
_type: HapticDirectionType, // The type of encoding.
|
||||||
dir: [3]i32, // The encoded direction.
|
dir: [3]i32, // The encoded direction.
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HapticConstant = extern struct {
|
pub const HapticConstant = extern struct {
|
||||||
_type: u16, // SDL_HAPTIC_CONSTANT
|
_type: HapticEffectType, // SDL_HAPTIC_CONSTANT
|
||||||
direction: HapticDirection, // Direction of the effect.
|
direction: HapticDirection, // Direction of the effect.
|
||||||
length: u32, // Duration of the effect.
|
length: u32, // Duration of the effect.
|
||||||
delay: u16, // Delay before starting the effect.
|
delay: u16, // Delay before starting the effect.
|
||||||
|
|
@ -155,7 +161,7 @@ pub const HapticCondition = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HapticRamp = extern struct {
|
pub const HapticRamp = extern struct {
|
||||||
_type: u16, // SDL_HAPTIC_RAMP
|
_type: HapticEffectType, // SDL_HAPTIC_RAMP
|
||||||
direction: HapticDirection, // Direction of the effect.
|
direction: HapticDirection, // Direction of the effect.
|
||||||
length: u32, // Duration of the effect.
|
length: u32, // Duration of the effect.
|
||||||
delay: u16, // Delay before starting the effect.
|
delay: u16, // Delay before starting the effect.
|
||||||
|
|
@ -170,14 +176,14 @@ pub const HapticRamp = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HapticLeftRight = extern struct {
|
pub const HapticLeftRight = extern struct {
|
||||||
_type: u16, // SDL_HAPTIC_LEFTRIGHT
|
_type: HapticEffectType, // SDL_HAPTIC_LEFTRIGHT
|
||||||
length: u32, // Duration of the effect in milliseconds.
|
length: u32, // Duration of the effect in milliseconds.
|
||||||
large_magnitude: u16, // Control of the large controller motor.
|
large_magnitude: u16, // Control of the large controller motor.
|
||||||
small_magnitude: u16, // Control of the small controller motor.
|
small_magnitude: u16, // Control of the small controller motor.
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HapticCustom = extern struct {
|
pub const HapticCustom = extern struct {
|
||||||
_type: u16, // SDL_HAPTIC_CUSTOM
|
_type: HapticEffectType, // SDL_HAPTIC_CUSTOM
|
||||||
direction: HapticDirection, // Direction of the effect.
|
direction: HapticDirection, // Direction of the effect.
|
||||||
length: u32, // Duration of the effect.
|
length: u32, // Duration of the effect.
|
||||||
delay: u16, // Delay before starting the effect.
|
delay: u16, // Delay before starting the effect.
|
||||||
|
|
@ -194,7 +200,7 @@ pub const HapticCustom = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HapticEffect = extern union {
|
pub const HapticEffect = extern union {
|
||||||
_type: u16, // Effect type.
|
_type: HapticEffectType, // Effect type.
|
||||||
constant: HapticConstant, // Constant effect.
|
constant: HapticConstant, // Constant effect.
|
||||||
periodic: HapticPeriodic, // Periodic effect.
|
periodic: HapticPeriodic, // Periodic effect.
|
||||||
condition: HapticCondition, // Condition effect.
|
condition: HapticCondition, // Condition effect.
|
||||||
|
|
@ -206,7 +212,7 @@ pub const HapticEffect = extern union {
|
||||||
pub const HapticID = u32;
|
pub const HapticID = u32;
|
||||||
|
|
||||||
pub inline fn getHaptics(count: *c_int) ?*HapticID {
|
pub inline fn getHaptics(count: *c_int) ?*HapticID {
|
||||||
return c.SDL_GetHaptics(@ptrCast(count));
|
return @ptrCast(c.SDL_GetHaptics(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticNameForID(instance_id: HapticID) [*c]const u8 {
|
pub inline fn getHapticNameForID(instance_id: HapticID) [*c]const u8 {
|
||||||
|
|
@ -214,17 +220,17 @@ pub inline fn getHapticNameForID(instance_id: HapticID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openHaptic(instance_id: HapticID) ?*Haptic {
|
pub inline fn openHaptic(instance_id: HapticID) ?*Haptic {
|
||||||
return c.SDL_OpenHaptic(instance_id);
|
return @ptrCast(c.SDL_OpenHaptic(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHapticFromID(instance_id: HapticID) ?*Haptic {
|
pub inline fn getHapticFromID(instance_id: HapticID) ?*Haptic {
|
||||||
return c.SDL_GetHapticFromID(instance_id);
|
return @ptrCast(c.SDL_GetHapticFromID(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isMouseHaptic() bool {
|
pub inline fn isMouseHaptic() bool {
|
||||||
return c.SDL_IsMouseHaptic();
|
return @bitCast(c.SDL_IsMouseHaptic());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openHapticFromMouse() ?*Haptic {
|
pub inline fn openHapticFromMouse() ?*Haptic {
|
||||||
return c.SDL_OpenHapticFromMouse();
|
return @ptrCast(c.SDL_OpenHapticFromMouse());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,15 @@ pub const HintPriority = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn setHintWithPriority(name: [*c]const u8, value: [*c]const u8, priority: HintPriority) bool {
|
pub inline fn setHintWithPriority(name: [*c]const u8, value: [*c]const u8, priority: HintPriority) bool {
|
||||||
return c.SDL_SetHintWithPriority(name, value, priority);
|
return @bitCast(c.SDL_SetHintWithPriority(name, value, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setHint(name: [*c]const u8, value: [*c]const u8) bool {
|
pub inline fn setHint(name: [*c]const u8, value: [*c]const u8) bool {
|
||||||
return c.SDL_SetHint(name, value);
|
return @bitCast(c.SDL_SetHint(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn resetHint(name: [*c]const u8) bool {
|
pub inline fn resetHint(name: [*c]const u8) bool {
|
||||||
return c.SDL_ResetHint(name);
|
return @bitCast(c.SDL_ResetHint(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn resetHints() void {
|
pub inline fn resetHints() void {
|
||||||
|
|
@ -28,13 +28,13 @@ pub inline fn getHint(name: [*c]const u8) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getHintBoolean(name: [*c]const u8, default_value: bool) bool {
|
pub inline fn getHintBoolean(name: [*c]const u8, default_value: bool) bool {
|
||||||
return c.SDL_GetHintBoolean(name, default_value);
|
return @bitCast(c.SDL_GetHintBoolean(name, @bitCast(default_value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const HintCallback = c.SDL_HintCallback;
|
pub const HintCallback = c.SDL_HintCallback;
|
||||||
|
|
||||||
pub inline fn addHintCallback(name: [*c]const u8, callback: HintCallback, userdata: ?*anyopaque) bool {
|
pub inline fn addHintCallback(name: [*c]const u8, callback: HintCallback, userdata: ?*anyopaque) bool {
|
||||||
return c.SDL_AddHintCallback(name, callback, userdata);
|
return @bitCast(c.SDL_AddHintCallback(name, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removeHintCallback(name: [*c]const u8, callback: HintCallback, userdata: ?*anyopaque) void {
|
pub inline fn removeHintCallback(name: [*c]const u8, callback: HintCallback, userdata: ?*anyopaque) void {
|
||||||
|
|
|
||||||
14
api/init.zig
14
api/init.zig
|
|
@ -12,6 +12,8 @@ pub const InitFlags = packed struct(u32) {
|
||||||
initCamera: bool = false, // `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS`
|
initCamera: bool = false, // `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS`
|
||||||
pad0: u23 = 0,
|
pad0: u23 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = InitFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const AppResult = enum(c_int) {
|
pub const AppResult = enum(c_int) {
|
||||||
|
|
@ -29,11 +31,11 @@ pub const AppEvent_func = c.SDL_AppEvent_func;
|
||||||
pub const AppQuit_func = c.SDL_AppQuit_func;
|
pub const AppQuit_func = c.SDL_AppQuit_func;
|
||||||
|
|
||||||
pub inline fn init(flags: InitFlags) bool {
|
pub inline fn init(flags: InitFlags) bool {
|
||||||
return c.SDL_Init(@bitCast(flags));
|
return @bitCast(c.SDL_Init(@bitCast(flags)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn initSubSystem(flags: InitFlags) bool {
|
pub inline fn initSubSystem(flags: InitFlags) bool {
|
||||||
return c.SDL_InitSubSystem(@bitCast(flags));
|
return @bitCast(c.SDL_InitSubSystem(@bitCast(flags)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn quitSubSystem(flags: InitFlags) void {
|
pub inline fn quitSubSystem(flags: InitFlags) void {
|
||||||
|
|
@ -49,21 +51,21 @@ pub inline fn quit() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isMainThread() bool {
|
pub inline fn isMainThread() bool {
|
||||||
return c.SDL_IsMainThread();
|
return @bitCast(c.SDL_IsMainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const MainThreadCallback = c.SDL_MainThreadCallback;
|
pub const MainThreadCallback = c.SDL_MainThreadCallback;
|
||||||
|
|
||||||
pub inline fn runOnMainThread(callback: MainThreadCallback, userdata: ?*anyopaque, wait_complete: bool) bool {
|
pub inline fn runOnMainThread(callback: MainThreadCallback, userdata: ?*anyopaque, wait_complete: bool) bool {
|
||||||
return c.SDL_RunOnMainThread(callback, userdata, wait_complete);
|
return @bitCast(c.SDL_RunOnMainThread(callback, userdata, @bitCast(wait_complete)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAppMetadata(appname: [*c]const u8, appversion: [*c]const u8, appidentifier: [*c]const u8) bool {
|
pub inline fn setAppMetadata(appname: [*c]const u8, appversion: [*c]const u8, appidentifier: [*c]const u8) bool {
|
||||||
return c.SDL_SetAppMetadata(appname, appversion, appidentifier);
|
return @bitCast(c.SDL_SetAppMetadata(appname, appversion, appidentifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setAppMetadataProperty(name: [*c]const u8, value: [*c]const u8) bool {
|
pub inline fn setAppMetadataProperty(name: [*c]const u8, value: [*c]const u8) bool {
|
||||||
return c.SDL_SetAppMetadataProperty(name, value);
|
return @bitCast(c.SDL_SetAppMetadataProperty(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAppMetadataProperty(name: [*c]const u8) [*c]const u8 {
|
pub inline fn getAppMetadataProperty(name: [*c]const u8) [*c]const u8 {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ pub const c = @import("c.zig").c;
|
||||||
pub const PropertiesID = u32;
|
pub const PropertiesID = u32;
|
||||||
|
|
||||||
pub const SensorType = enum(c_int) {
|
pub const SensorType = enum(c_int) {
|
||||||
sensorInvalid, //Returned for an invalid sensor
|
sensorInvalid = -1, //Returned for an invalid sensor
|
||||||
sensorUnknown, //Unknown sensor type
|
sensorUnknown, //Unknown sensor type
|
||||||
sensorAccel, //Accelerometer
|
sensorAccel, //Accelerometer
|
||||||
sensorGyro, //Gyroscope
|
sensorGyro, //Gyroscope
|
||||||
|
|
@ -20,7 +20,7 @@ pub const GUID = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PowerState = enum(c_int) {
|
pub const PowerState = enum(c_int) {
|
||||||
powerstateError, //error determining power status
|
powerstateError = -1, //error determining power status
|
||||||
powerstateUnknown, //cannot determine power status
|
powerstateUnknown, //cannot determine power status
|
||||||
powerstateOnBattery, //Not plugged in, running on the battery
|
powerstateOnBattery, //Not plugged in, running on the battery
|
||||||
powerstateNoBattery, //Plugged in, no battery available
|
powerstateNoBattery, //Plugged in, no battery available
|
||||||
|
|
@ -30,147 +30,147 @@ pub const PowerState = enum(c_int) {
|
||||||
|
|
||||||
pub const Joystick = opaque {
|
pub const Joystick = opaque {
|
||||||
pub inline fn setJoystickVirtualAxis(joystick: *Joystick, axis: c_int, value: i16) bool {
|
pub inline fn setJoystickVirtualAxis(joystick: *Joystick, axis: c_int, value: i16) bool {
|
||||||
return c.SDL_SetJoystickVirtualAxis(joystick, axis, value);
|
return @bitCast(c.SDL_SetJoystickVirtualAxis(@ptrCast(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);
|
return @bitCast(c.SDL_SetJoystickVirtualBall(@ptrCast(joystick), ball, xrel, yrel));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickVirtualButton(joystick: *Joystick, button: c_int, down: bool) bool {
|
pub inline fn setJoystickVirtualButton(joystick: *Joystick, button: c_int, down: bool) bool {
|
||||||
return c.SDL_SetJoystickVirtualButton(joystick, button, down);
|
return @bitCast(c.SDL_SetJoystickVirtualButton(@ptrCast(joystick), button, @bitCast(down)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickVirtualHat(joystick: *Joystick, hat: c_int, value: u8) bool {
|
pub inline fn setJoystickVirtualHat(joystick: *Joystick, hat: c_int, value: u8) bool {
|
||||||
return c.SDL_SetJoystickVirtualHat(joystick, hat, value);
|
return @bitCast(c.SDL_SetJoystickVirtualHat(@ptrCast(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);
|
return @bitCast(c.SDL_SetJoystickVirtualTouchpad(@ptrCast(joystick), touchpad, finger, @bitCast(down), x, y, pressure));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn sendJoystickVirtualSensorData(joystick: *Joystick, _type: SensorType, sensor_timestamp: u64, data: *const f32, num_values: c_int) bool {
|
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);
|
return @bitCast(c.SDL_SendJoystickVirtualSensorData(@ptrCast(joystick), @intFromEnum(_type), sensor_timestamp, @ptrCast(data), num_values));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickProperties(joystick: *Joystick) PropertiesID {
|
pub inline fn getJoystickProperties(joystick: *Joystick) PropertiesID {
|
||||||
return c.SDL_GetJoystickProperties(joystick);
|
return c.SDL_GetJoystickProperties(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickName(joystick: *Joystick) [*c]const u8 {
|
pub inline fn getJoystickName(joystick: *Joystick) [*c]const u8 {
|
||||||
return c.SDL_GetJoystickName(joystick);
|
return c.SDL_GetJoystickName(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickPath(joystick: *Joystick) [*c]const u8 {
|
pub inline fn getJoystickPath(joystick: *Joystick) [*c]const u8 {
|
||||||
return c.SDL_GetJoystickPath(joystick);
|
return c.SDL_GetJoystickPath(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickPlayerIndex(joystick: *Joystick) c_int {
|
pub inline fn getJoystickPlayerIndex(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetJoystickPlayerIndex(joystick);
|
return c.SDL_GetJoystickPlayerIndex(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickPlayerIndex(joystick: *Joystick, player_index: c_int) bool {
|
pub inline fn setJoystickPlayerIndex(joystick: *Joystick, player_index: c_int) bool {
|
||||||
return c.SDL_SetJoystickPlayerIndex(joystick, player_index);
|
return @bitCast(c.SDL_SetJoystickPlayerIndex(@ptrCast(joystick), player_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickGUID(joystick: *Joystick) GUID {
|
pub inline fn getJoystickGUID(joystick: *Joystick) GUID {
|
||||||
return c.SDL_GetJoystickGUID(joystick);
|
return c.SDL_GetJoystickGUID(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickVendor(joystick: *Joystick) u16 {
|
pub inline fn getJoystickVendor(joystick: *Joystick) u16 {
|
||||||
return c.SDL_GetJoystickVendor(joystick);
|
return c.SDL_GetJoystickVendor(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickProduct(joystick: *Joystick) u16 {
|
pub inline fn getJoystickProduct(joystick: *Joystick) u16 {
|
||||||
return c.SDL_GetJoystickProduct(joystick);
|
return c.SDL_GetJoystickProduct(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickProductVersion(joystick: *Joystick) u16 {
|
pub inline fn getJoystickProductVersion(joystick: *Joystick) u16 {
|
||||||
return c.SDL_GetJoystickProductVersion(joystick);
|
return c.SDL_GetJoystickProductVersion(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickFirmwareVersion(joystick: *Joystick) u16 {
|
pub inline fn getJoystickFirmwareVersion(joystick: *Joystick) u16 {
|
||||||
return c.SDL_GetJoystickFirmwareVersion(joystick);
|
return c.SDL_GetJoystickFirmwareVersion(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickSerial(joystick: *Joystick) [*c]const u8 {
|
pub inline fn getJoystickSerial(joystick: *Joystick) [*c]const u8 {
|
||||||
return c.SDL_GetJoystickSerial(joystick);
|
return c.SDL_GetJoystickSerial(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickType(joystick: *Joystick) JoystickType {
|
pub inline fn getJoystickType(joystick: *Joystick) JoystickType {
|
||||||
return @intFromEnum(c.SDL_GetJoystickType(joystick));
|
return @intFromEnum(c.SDL_GetJoystickType(@ptrCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn joystickConnected(joystick: *Joystick) bool {
|
pub inline fn joystickConnected(joystick: *Joystick) bool {
|
||||||
return c.SDL_JoystickConnected(joystick);
|
return @bitCast(c.SDL_JoystickConnected(@ptrCast(joystick)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickID(joystick: *Joystick) JoystickID {
|
pub inline fn getJoystickID(joystick: *Joystick) JoystickID {
|
||||||
return c.SDL_GetJoystickID(joystick);
|
return c.SDL_GetJoystickID(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumJoystickAxes(joystick: *Joystick) c_int {
|
pub inline fn getNumJoystickAxes(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetNumJoystickAxes(joystick);
|
return c.SDL_GetNumJoystickAxes(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumJoystickBalls(joystick: *Joystick) c_int {
|
pub inline fn getNumJoystickBalls(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetNumJoystickBalls(joystick);
|
return c.SDL_GetNumJoystickBalls(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumJoystickHats(joystick: *Joystick) c_int {
|
pub inline fn getNumJoystickHats(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetNumJoystickHats(joystick);
|
return c.SDL_GetNumJoystickHats(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNumJoystickButtons(joystick: *Joystick) c_int {
|
pub inline fn getNumJoystickButtons(joystick: *Joystick) c_int {
|
||||||
return c.SDL_GetNumJoystickButtons(joystick);
|
return c.SDL_GetNumJoystickButtons(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickAxis(joystick: *Joystick, axis: c_int) i16 {
|
pub inline fn getJoystickAxis(joystick: *Joystick, axis: c_int) i16 {
|
||||||
return c.SDL_GetJoystickAxis(joystick, axis);
|
return c.SDL_GetJoystickAxis(@ptrCast(joystick), axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickAxisInitialState(joystick: *Joystick, axis: c_int, state: *i16) bool {
|
pub inline fn getJoystickAxisInitialState(joystick: *Joystick, axis: c_int, state: *i16) bool {
|
||||||
return c.SDL_GetJoystickAxisInitialState(joystick, axis, @ptrCast(state));
|
return @bitCast(c.SDL_GetJoystickAxisInitialState(@ptrCast(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));
|
return @bitCast(c.SDL_GetJoystickBall(@ptrCast(joystick), ball, @ptrCast(dx), @ptrCast(dy)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickHat(joystick: *Joystick, hat: c_int) u8 {
|
pub inline fn getJoystickHat(joystick: *Joystick, hat: c_int) u8 {
|
||||||
return c.SDL_GetJoystickHat(joystick, hat);
|
return c.SDL_GetJoystickHat(@ptrCast(joystick), hat);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickButton(joystick: *Joystick, button: c_int) bool {
|
pub inline fn getJoystickButton(joystick: *Joystick, button: c_int) bool {
|
||||||
return c.SDL_GetJoystickButton(joystick, button);
|
return @bitCast(c.SDL_GetJoystickButton(@ptrCast(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);
|
return @bitCast(c.SDL_RumbleJoystick(@ptrCast(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);
|
return @bitCast(c.SDL_RumbleJoystickTriggers(@ptrCast(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);
|
return @bitCast(c.SDL_SetJoystickLED(@ptrCast(joystick), red, green, blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn sendJoystickEffect(joystick: *Joystick, data: ?*const anyopaque, size: c_int) bool {
|
pub inline fn sendJoystickEffect(joystick: *Joystick, data: ?*const anyopaque, size: c_int) bool {
|
||||||
return c.SDL_SendJoystickEffect(joystick, data, size);
|
return @bitCast(c.SDL_SendJoystickEffect(@ptrCast(joystick), data, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeJoystick(joystick: *Joystick) void {
|
pub inline fn closeJoystick(joystick: *Joystick) void {
|
||||||
return c.SDL_CloseJoystick(joystick);
|
return c.SDL_CloseJoystick(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickConnectionState(joystick: *Joystick) JoystickConnectionState {
|
pub inline fn getJoystickConnectionState(joystick: *Joystick) JoystickConnectionState {
|
||||||
return c.SDL_GetJoystickConnectionState(joystick);
|
return c.SDL_GetJoystickConnectionState(@ptrCast(joystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickPowerInfo(joystick: *Joystick, percent: *c_int) PowerState {
|
pub inline fn getJoystickPowerInfo(joystick: *Joystick, percent: *c_int) PowerState {
|
||||||
return c.SDL_GetJoystickPowerInfo(joystick, @ptrCast(percent));
|
return c.SDL_GetJoystickPowerInfo(@ptrCast(joystick), @ptrCast(percent));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -205,11 +205,11 @@ pub inline fn unlockJoysticks() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasJoystick() bool {
|
pub inline fn hasJoystick() bool {
|
||||||
return c.SDL_HasJoystick();
|
return @bitCast(c.SDL_HasJoystick());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoysticks(count: *c_int) ?*JoystickID {
|
pub inline fn getJoysticks(count: *c_int) ?*JoystickID {
|
||||||
return c.SDL_GetJoysticks(@ptrCast(count));
|
return @ptrCast(c.SDL_GetJoysticks(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickNameForID(instance_id: JoystickID) [*c]const u8 {
|
pub inline fn getJoystickNameForID(instance_id: JoystickID) [*c]const u8 {
|
||||||
|
|
@ -245,15 +245,15 @@ pub inline fn getJoystickTypeForID(instance_id: JoystickID) JoystickType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openJoystick(instance_id: JoystickID) ?*Joystick {
|
pub inline fn openJoystick(instance_id: JoystickID) ?*Joystick {
|
||||||
return c.SDL_OpenJoystick(instance_id);
|
return @ptrCast(c.SDL_OpenJoystick(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickFromID(instance_id: JoystickID) ?*Joystick {
|
pub inline fn getJoystickFromID(instance_id: JoystickID) ?*Joystick {
|
||||||
return c.SDL_GetJoystickFromID(instance_id);
|
return @ptrCast(c.SDL_GetJoystickFromID(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickFromPlayerIndex(player_index: c_int) ?*Joystick {
|
pub inline fn getJoystickFromPlayerIndex(player_index: c_int) ?*Joystick {
|
||||||
return c.SDL_GetJoystickFromPlayerIndex(player_index);
|
return @ptrCast(c.SDL_GetJoystickFromPlayerIndex(player_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const VirtualJoystickTouchpadDesc = extern struct {
|
pub const VirtualJoystickTouchpadDesc = extern struct {
|
||||||
|
|
@ -298,11 +298,11 @@ pub inline fn attachVirtualJoystick(desc: *const VirtualJoystickDesc) JoystickID
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn detachVirtualJoystick(instance_id: JoystickID) bool {
|
pub inline fn detachVirtualJoystick(instance_id: JoystickID) bool {
|
||||||
return c.SDL_DetachVirtualJoystick(instance_id);
|
return @bitCast(c.SDL_DetachVirtualJoystick(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isJoystickVirtual(instance_id: JoystickID) bool {
|
pub inline fn isJoystickVirtual(instance_id: JoystickID) bool {
|
||||||
return c.SDL_IsJoystickVirtual(instance_id);
|
return @bitCast(c.SDL_IsJoystickVirtual(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getJoystickGUIDInfo(guid: GUID, vendor: *u16, product: *u16, version: *u16, crc16: *u16) void {
|
pub inline fn getJoystickGUIDInfo(guid: GUID, vendor: *u16, product: *u16, version: *u16, crc16: *u16) void {
|
||||||
|
|
@ -310,11 +310,11 @@ pub inline fn getJoystickGUIDInfo(guid: GUID, vendor: *u16, product: *u16, versi
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setJoystickEventsEnabled(enabled: bool) void {
|
pub inline fn setJoystickEventsEnabled(enabled: bool) void {
|
||||||
return c.SDL_SetJoystickEventsEnabled(enabled);
|
return c.SDL_SetJoystickEventsEnabled(@bitCast(enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn joystickEventsEnabled() bool {
|
pub inline fn joystickEventsEnabled() bool {
|
||||||
return c.SDL_JoystickEventsEnabled();
|
return @bitCast(c.SDL_JoystickEventsEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateJoysticks() void {
|
pub inline fn updateJoysticks() void {
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@ pub const FunctionPointer = c.SDL_FunctionPointer;
|
||||||
|
|
||||||
pub const SharedObject = opaque {
|
pub const SharedObject = opaque {
|
||||||
pub inline fn loadFunction(sharedobject: *SharedObject, name: [*c]const u8) FunctionPointer {
|
pub inline fn loadFunction(sharedobject: *SharedObject, name: [*c]const u8) FunctionPointer {
|
||||||
return c.SDL_LoadFunction(sharedobject, name);
|
return c.SDL_LoadFunction(@ptrCast(sharedobject), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unloadObject(sharedobject: *SharedObject) void {
|
pub inline fn unloadObject(sharedobject: *SharedObject) void {
|
||||||
return c.SDL_UnloadObject(sharedobject);
|
return c.SDL_UnloadObject(@ptrCast(sharedobject));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn loadObject(sofile: [*c]const u8) ?*SharedObject {
|
pub inline fn loadObject(sofile: [*c]const u8) ?*SharedObject {
|
||||||
return c.SDL_LoadObject(sofile);
|
return @ptrCast(c.SDL_LoadObject(sofile));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ pub const MessageBoxFlags = packed struct(u32) {
|
||||||
messageboxButtonsRightToLeft: bool = false, // buttons placed right to left
|
messageboxButtonsRightToLeft: bool = false, // buttons placed right to left
|
||||||
pad0: u26 = 0,
|
pad0: u26 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = MessageBoxFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MessageBoxButtonFlags = packed struct(u32) {
|
pub const MessageBoxButtonFlags = packed struct(u32) {
|
||||||
|
|
@ -18,6 +20,8 @@ pub const MessageBoxButtonFlags = packed struct(u32) {
|
||||||
messageboxButtonEscapekeyDefault: bool = false, // Marks the default button when escape is hit
|
messageboxButtonEscapekeyDefault: bool = false, // Marks the default button when escape is hit
|
||||||
pad0: u29 = 0,
|
pad0: u29 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = MessageBoxButtonFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MessageBoxButtonData = extern struct {
|
pub const MessageBoxButtonData = extern struct {
|
||||||
|
|
@ -56,9 +60,9 @@ pub const MessageBoxData = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn showMessageBox(messageboxdata: *const MessageBoxData, buttonid: *c_int) bool {
|
pub inline fn showMessageBox(messageboxdata: *const MessageBoxData, buttonid: *c_int) bool {
|
||||||
return c.SDL_ShowMessageBox(@ptrCast(messageboxdata), @ptrCast(buttonid));
|
return @bitCast(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);
|
return @bitCast(c.SDL_ShowSimpleMessageBox(@bitCast(flags), title, message, @ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@ const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub inline fn openURL(url: [*c]const u8) bool {
|
pub inline fn openURL(url: [*c]const u8) bool {
|
||||||
return c.SDL_OpenURL(url);
|
return @bitCast(c.SDL_OpenURL(url));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,21 @@ pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub const Window = opaque {
|
pub const Window = opaque {
|
||||||
pub inline fn warpMouseInWindow(window: *Window, x: f32, y: f32) void {
|
pub inline fn warpMouseInWindow(window: *Window, x: f32, y: f32) void {
|
||||||
return c.SDL_WarpMouseInWindow(window, x, y);
|
return c.SDL_WarpMouseInWindow(@ptrCast(window), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowRelativeMouseMode(window: *Window, enabled: bool) bool {
|
pub inline fn setWindowRelativeMouseMode(window: *Window, enabled: bool) bool {
|
||||||
return c.SDL_SetWindowRelativeMouseMode(window, enabled);
|
return @bitCast(c.SDL_SetWindowRelativeMouseMode(@ptrCast(window), @bitCast(enabled)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowRelativeMouseMode(window: *Window) bool {
|
pub inline fn getWindowRelativeMouseMode(window: *Window) bool {
|
||||||
return c.SDL_GetWindowRelativeMouseMode(window);
|
return @bitCast(c.SDL_GetWindowRelativeMouseMode(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Surface = opaque {
|
pub const Surface = opaque {
|
||||||
pub inline fn createColorCursor(surface: *Surface, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
pub inline fn createColorCursor(surface: *Surface, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
||||||
return c.SDL_CreateColorCursor(surface, hot_x, hot_y);
|
return @ptrCast(c.SDL_CreateColorCursor(@ptrCast(surface), hot_x, hot_y));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -25,11 +25,11 @@ pub const MouseID = u32;
|
||||||
|
|
||||||
pub const Cursor = opaque {
|
pub const Cursor = opaque {
|
||||||
pub inline fn setCursor(cursor: *Cursor) bool {
|
pub inline fn setCursor(cursor: *Cursor) bool {
|
||||||
return c.SDL_SetCursor(cursor);
|
return @bitCast(c.SDL_SetCursor(@ptrCast(cursor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyCursor(cursor: *Cursor) void {
|
pub inline fn destroyCursor(cursor: *Cursor) void {
|
||||||
return c.SDL_DestroyCursor(cursor);
|
return c.SDL_DestroyCursor(@ptrCast(cursor));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -62,20 +62,29 @@ pub const MouseWheelDirection = enum(c_int) {
|
||||||
mousewheelFlipped, //The scroll direction is flipped / natural
|
mousewheelFlipped, //The scroll direction is flipped / natural
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const CursorFrameInfo = extern struct {
|
||||||
|
surface: ?*Surface, // The surface data for this frame
|
||||||
|
duration: u32, // The frame duration in milliseconds (a duration of 0 is infinite)
|
||||||
|
};
|
||||||
|
|
||||||
pub const MouseButtonFlags = packed struct(u32) {
|
pub const MouseButtonFlags = packed struct(u32) {
|
||||||
buttonLeft: bool = false,
|
buttonLeft: bool = false,
|
||||||
buttonMiddle: bool = false,
|
buttonMiddle: bool = false,
|
||||||
buttonX1: bool = false,
|
buttonX1: bool = false,
|
||||||
pad0: u28 = 0,
|
pad0: u28 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = MouseButtonFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const MouseMotionTransformCallback = c.SDL_MouseMotionTransformCallback;
|
||||||
|
|
||||||
pub inline fn hasMouse() bool {
|
pub inline fn hasMouse() bool {
|
||||||
return c.SDL_HasMouse();
|
return @bitCast(c.SDL_HasMouse());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMice(count: *c_int) ?*MouseID {
|
pub inline fn getMice(count: *c_int) ?*MouseID {
|
||||||
return c.SDL_GetMice(@ptrCast(count));
|
return @ptrCast(c.SDL_GetMice(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMouseNameForID(instance_id: MouseID) [*c]const u8 {
|
pub inline fn getMouseNameForID(instance_id: MouseID) [*c]const u8 {
|
||||||
|
|
@ -83,7 +92,7 @@ pub inline fn getMouseNameForID(instance_id: MouseID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMouseFocus() ?*Window {
|
pub inline fn getMouseFocus() ?*Window {
|
||||||
return c.SDL_GetMouseFocus();
|
return @ptrCast(c.SDL_GetMouseFocus());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getMouseState(x: *f32, y: *f32) MouseButtonFlags {
|
pub inline fn getMouseState(x: *f32, y: *f32) MouseButtonFlags {
|
||||||
|
|
@ -99,37 +108,45 @@ pub inline fn getRelativeMouseState(x: *f32, y: *f32) MouseButtonFlags {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn warpMouseGlobal(x: f32, y: f32) bool {
|
pub inline fn warpMouseGlobal(x: f32, y: f32) bool {
|
||||||
return c.SDL_WarpMouseGlobal(x, y);
|
return @bitCast(c.SDL_WarpMouseGlobal(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn setRelativeMouseTransform(callback: MouseMotionTransformCallback, userdata: ?*anyopaque) bool {
|
||||||
|
return @bitCast(c.SDL_SetRelativeMouseTransform(callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn captureMouse(enabled: bool) bool {
|
pub inline fn captureMouse(enabled: bool) bool {
|
||||||
return c.SDL_CaptureMouse(enabled);
|
return @bitCast(c.SDL_CaptureMouse(@bitCast(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);
|
return @ptrCast(c.SDL_CreateCursor(data, mask, w, h, hot_x, hot_y));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn createAnimatedCursor(frames: ?*CursorFrameInfo, frame_count: c_int, hot_x: c_int, hot_y: c_int) ?*Cursor {
|
||||||
|
return @ptrCast(c.SDL_CreateAnimatedCursor(@ptrCast(frames), frame_count, hot_x, hot_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createSystemCursor(id: SystemCursor) ?*Cursor {
|
pub inline fn createSystemCursor(id: SystemCursor) ?*Cursor {
|
||||||
return c.SDL_CreateSystemCursor(id);
|
return @ptrCast(c.SDL_CreateSystemCursor(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCursor() ?*Cursor {
|
pub inline fn getCursor() ?*Cursor {
|
||||||
return c.SDL_GetCursor();
|
return @ptrCast(c.SDL_GetCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDefaultCursor() ?*Cursor {
|
pub inline fn getDefaultCursor() ?*Cursor {
|
||||||
return c.SDL_GetDefaultCursor();
|
return @ptrCast(c.SDL_GetDefaultCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showCursor() bool {
|
pub inline fn showCursor() bool {
|
||||||
return c.SDL_ShowCursor();
|
return @bitCast(c.SDL_ShowCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hideCursor() bool {
|
pub inline fn hideCursor() bool {
|
||||||
return c.SDL_HideCursor();
|
return @bitCast(c.SDL_HideCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn cursorVisible() bool {
|
pub inline fn cursorVisible() bool {
|
||||||
return c.SDL_CursorVisible();
|
return @bitCast(c.SDL_CursorVisible());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
139
api/pixels.zig
139
api/pixels.zig
|
|
@ -58,99 +58,100 @@ pub const PackedLayout = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PixelFormat = enum(c_int) {
|
pub const PixelFormat = enum(c_int) {
|
||||||
pixelformatYv12, //Planar mode: Y + V + U (3 planes)
|
pixelformatYv12 = 0x32315659, //Planar mode: Y + V + U (3 planes)
|
||||||
pixelformatIyuv, //Planar mode: Y + U + V (3 planes)
|
pixelformatIyuv = 0x56555949, //Planar mode: Y + U + V (3 planes)
|
||||||
pixelformatYuy2, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
pixelformatYuy2 = 0x32595559, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
||||||
pixelformatUyvy, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
pixelformatUyvy = 0x59565955, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
||||||
pixelformatYvyu, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
pixelformatYvyu = 0x55595659, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
||||||
pixelformatNv12, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatNv12 = 0x3231564e, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatNv21, //Planar mode: Y + V/U interleaved (2 planes)
|
pixelformatNv21 = 0x3132564e, //Planar mode: Y + V/U interleaved (2 planes)
|
||||||
pixelformatP010, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatP010 = 0x30313050, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatExternalOes, //Android video texture format
|
pixelformatExternalOes = 0x2053454f, //Android video texture format
|
||||||
pixelformatMjpg, //Motion JPEG
|
pixelformatMjpg = 0x47504a4d, //Motion JPEG
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ColorRange = enum(c_int) {
|
pub const ColorRange = enum(c_int) {
|
||||||
colorRangeLimited, //Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma
|
colorRangeLimited = 1, //Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma
|
||||||
colorRangeFull,
|
colorRangeFull = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ColorPrimaries = enum(c_int) {
|
pub const ColorPrimaries = enum(c_int) {
|
||||||
colorPrimariesBt709, //ITU-R BT.709-6
|
colorPrimariesBt709 = 1, //ITU-R BT.709-6
|
||||||
colorPrimariesBt470m, //ITU-R BT.470-6 System M
|
colorPrimariesBt470m = 4, //ITU-R BT.470-6 System M
|
||||||
colorPrimariesBt470bg, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625
|
colorPrimariesBt470bg = 5, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625
|
||||||
colorPrimariesBt601, //ITU-R BT.601-7 525, SMPTE 170M
|
colorPrimariesBt601 = 6, //ITU-R BT.601-7 525, SMPTE 170M
|
||||||
colorPrimariesSmpte240, //SMPTE 240M, functionally the same as SDL_COLOR_PRIMARIES_BT601
|
colorPrimariesSmpte240 = 7, //SMPTE 240M, functionally the same as SDL_COLOR_PRIMARIES_BT601
|
||||||
colorPrimariesGenericFilm, //Generic film (color filters using Illuminant C)
|
colorPrimariesGenericFilm = 8, //Generic film (color filters using Illuminant C)
|
||||||
colorPrimariesBt2020, //ITU-R BT.2020-2 / ITU-R BT.2100-0
|
colorPrimariesBt2020 = 9, //ITU-R BT.2020-2 / ITU-R BT.2100-0
|
||||||
colorPrimariesXyz, //SMPTE ST 428-1
|
colorPrimariesXyz = 10, //SMPTE ST 428-1
|
||||||
colorPrimariesSmpte431, //SMPTE RP 431-2
|
colorPrimariesSmpte431 = 11, //SMPTE RP 431-2
|
||||||
colorPrimariesSmpte432, //SMPTE EG 432-1 / DCI P3
|
colorPrimariesSmpte432 = 12, //SMPTE EG 432-1 / DCI P3
|
||||||
colorPrimariesEbu3213, //EBU Tech. 3213-E
|
colorPrimariesEbu3213 = 22, //EBU Tech. 3213-E
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TransferCharacteristics = enum(c_int) {
|
pub const TransferCharacteristics = enum(c_int) {
|
||||||
transferCharacteristicsBt709, //Rec. ITU-R BT.709-6 / ITU-R BT1361
|
transferCharacteristicsBt709 = 1, //Rec. ITU-R BT.709-6 / ITU-R BT1361
|
||||||
transferCharacteristicsGamma22, //ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM
|
transferCharacteristicsGamma22 = 4, //ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM
|
||||||
transferCharacteristicsGamma28, //ITU-R BT.470-6 System B, G
|
transferCharacteristicsGamma28 = 5, //ITU-R BT.470-6 System B, G
|
||||||
transferCharacteristicsBt601, //SMPTE ST 170M / ITU-R BT.601-7 525 or 625
|
transferCharacteristicsBt601 = 6, //SMPTE ST 170M / ITU-R BT.601-7 525 or 625
|
||||||
transferCharacteristicsSmpte240, //SMPTE ST 240M
|
transferCharacteristicsSmpte240 = 7, //SMPTE ST 240M
|
||||||
transferCharacteristicsIec61966, //IEC 61966-2-4
|
transferCharacteristicsIec61966 = 11, //IEC 61966-2-4
|
||||||
transferCharacteristicsBt1361, //ITU-R BT1361 Extended Colour Gamut
|
transferCharacteristicsBt1361 = 12, //ITU-R BT1361 Extended Colour Gamut
|
||||||
transferCharacteristicsSrgb, //IEC 61966-2-1 (sRGB or sYCC)
|
transferCharacteristicsSrgb = 13, //IEC 61966-2-1 (sRGB or sYCC)
|
||||||
transferCharacteristicsBt202010bit, //ITU-R BT2020 for 10-bit system
|
transferCharacteristicsBt202010bit = 14, //ITU-R BT2020 for 10-bit system
|
||||||
transferCharacteristicsBt202012bit, //ITU-R BT2020 for 12-bit system
|
transferCharacteristicsBt202012bit = 15, //ITU-R BT2020 for 12-bit system
|
||||||
transferCharacteristicsPq, //SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
|
transferCharacteristicsPq = 16, //SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
|
||||||
transferCharacteristicsSmpte428, //SMPTE ST 428-1
|
transferCharacteristicsSmpte428 = 17, //SMPTE ST 428-1
|
||||||
transferCharacteristicsHlg, //ARIB STD-B67, known as "hybrid log-gamma" (HLG)
|
transferCharacteristicsHlg = 18, //ARIB STD-B67, known as "hybrid log-gamma" (HLG)
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MatrixCoefficients = enum(c_int) {
|
pub const MatrixCoefficients = enum(c_int) {
|
||||||
matrixCoefficientsBt709, //ITU-R BT.709-6
|
matrixCoefficientsBt709 = 1, //ITU-R BT.709-6
|
||||||
matrixCoefficientsFcc, //US FCC Title 47
|
matrixCoefficientsFcc = 4, //US FCC Title 47
|
||||||
matrixCoefficientsBt470bg, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as SDL_MATRIX_COEFFICIENTS_BT601
|
matrixCoefficientsBt470bg = 5, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as SDL_MATRIX_COEFFICIENTS_BT601
|
||||||
matrixCoefficientsBt601, //ITU-R BT.601-7 525
|
matrixCoefficientsBt601 = 6, //ITU-R BT.601-7 525
|
||||||
matrixCoefficientsSmpte240, //SMPTE 240M
|
matrixCoefficientsSmpte240 = 7, //SMPTE 240M
|
||||||
matrixCoefficientsBt2020Ncl, //ITU-R BT.2020-2 non-constant luminance
|
matrixCoefficientsBt2020Ncl = 9, //ITU-R BT.2020-2 non-constant luminance
|
||||||
matrixCoefficientsBt2020Cl, //ITU-R BT.2020-2 constant luminance
|
matrixCoefficientsBt2020Cl = 10, //ITU-R BT.2020-2 constant luminance
|
||||||
matrixCoefficientsSmpte2085, //SMPTE ST 2085
|
matrixCoefficientsSmpte2085 = 11, //SMPTE ST 2085
|
||||||
matrixCoefficientsIctcp, //ITU-R BT.2100-0 ICTCP
|
matrixCoefficientsIctcp = 14, //ITU-R BT.2100-0 ICTCP
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ChromaLocation = enum(c_int) {
|
pub const ChromaLocation = enum(c_int) {
|
||||||
chromaLocationNone, //RGB, no chroma sampling
|
chromaLocationNone = 0, //RGB, no chroma sampling
|
||||||
chromaLocationLeft, //In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically.
|
chromaLocationLeft = 1, //In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically.
|
||||||
chromaLocationCenter, //In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel.
|
chromaLocationCenter = 2, //In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel.
|
||||||
chromaLocationTopleft,
|
chromaLocationTopleft = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Colorspace = enum(c_int) {
|
pub const Colorspace = enum(c_int) {
|
||||||
colorspaceSrgb, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
colorspaceSrgb = 0x120005a0, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
||||||
colorRangeFull,
|
colorRangeFull,
|
||||||
colorPrimariesBt709,
|
colorPrimariesBt709,
|
||||||
transferCharacteristicsSrgb,
|
transferCharacteristicsSrgb,
|
||||||
matrixCoefficientsIdentity,
|
matrixCoefficientsIdentity,
|
||||||
colorspaceSrgbLinear, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
colorspaceSrgbLinear = 0x12000500, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
||||||
transferCharacteristicsLinear,
|
transferCharacteristicsLinear,
|
||||||
colorspaceHdr10, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
colorspaceHdr10 = 0x12002600, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
||||||
colorPrimariesBt2020,
|
colorPrimariesBt2020,
|
||||||
transferCharacteristicsPq,
|
transferCharacteristicsPq,
|
||||||
colorspaceJpeg, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
colorspaceJpeg = 0x220004c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
||||||
transferCharacteristicsBt601,
|
transferCharacteristicsBt601,
|
||||||
matrixCoefficientsBt601,
|
matrixCoefficientsBt601,
|
||||||
colorspaceBt601Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
colorspaceBt601Limited = 0x211018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
||||||
colorRangeLimited,
|
colorRangeLimited,
|
||||||
colorPrimariesBt601,
|
colorPrimariesBt601,
|
||||||
colorspaceBt601Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
colorspaceBt601Full = 0x221018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
||||||
colorspaceBt709Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
colorspaceBt709Limited = 0x21100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
||||||
transferCharacteristicsBt709,
|
transferCharacteristicsBt709,
|
||||||
matrixCoefficientsBt709,
|
matrixCoefficientsBt709,
|
||||||
colorspaceBt709Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
colorspaceBt709Full = 0x22100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
||||||
colorspaceBt2020Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
colorspaceBt2020Limited = 0x21102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
||||||
matrixCoefficientsBt2020Ncl,
|
matrixCoefficientsBt2020Ncl,
|
||||||
colorspaceBt2020Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
colorspaceBt2020Full = 0x22102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
||||||
colorspaceRgbDefault, //The default colorspace for RGB surfaces if no colorspace is specified
|
|
||||||
colorspaceYuvDefault, //The default colorspace for YUV surfaces if no colorspace is specified
|
pub const colorspaceRgbDefault = .colorspaceSrgb; //The default colorspace for RGB surfaces if no colorspace is specified
|
||||||
|
pub const colorspaceYuvDefault = .colorspaceBt601Limited; //The default colorspace for YUV surfaces if no colorspace is specified
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Color = extern struct {
|
pub const Color = extern struct {
|
||||||
|
|
@ -198,7 +199,7 @@ pub inline fn getPixelFormatName(format: PixelFormat) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
return @bitCast(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 {
|
||||||
|
|
@ -210,15 +211,15 @@ pub inline fn getPixelFormatDetails(format: PixelFormat) *const PixelFormatDetai
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createPalette(ncolors: c_int) ?*Palette {
|
pub inline fn createPalette(ncolors: c_int) ?*Palette {
|
||||||
return 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 c.SDL_SetPaletteColors(palette, @ptrCast(colors), firstcolor, ncolors);
|
return @bitCast(c.SDL_SetPaletteColors(@ptrCast(palette), @ptrCast(colors), firstcolor, ncolors));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyPalette(palette: ?*Palette) void {
|
pub inline fn destroyPalette(palette: ?*Palette) void {
|
||||||
return c.SDL_DestroyPalette(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 {
|
||||||
|
|
@ -229,10 +230,10 @@ pub inline fn mapRGBA(format: *const PixelFormatDetails, palette: *const Palette
|
||||||
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(pixel: 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(pixel, @ptrCast(format), @ptrCast(palette), r, g, b);
|
return c.SDL_GetRGB(pixelvalue, @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(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(pixel, @ptrCast(format), @ptrCast(palette), r, g, b, a);
|
return c.SDL_GetRGBA(pixelvalue, @ptrCast(format), @ptrCast(palette), r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ pub inline fn createProperties() PropertiesID {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn copyProperties(src: PropertiesID, dst: PropertiesID) bool {
|
pub inline fn copyProperties(src: PropertiesID, dst: PropertiesID) bool {
|
||||||
return c.SDL_CopyProperties(src, dst);
|
return @bitCast(c.SDL_CopyProperties(src, dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn lockProperties(props: PropertiesID) bool {
|
pub inline fn lockProperties(props: PropertiesID) bool {
|
||||||
return c.SDL_LockProperties(props);
|
return @bitCast(c.SDL_LockProperties(props));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unlockProperties(props: PropertiesID) void {
|
pub inline fn unlockProperties(props: PropertiesID) void {
|
||||||
|
|
@ -35,31 +35,31 @@ pub inline fn unlockProperties(props: PropertiesID) void {
|
||||||
pub const CleanupPropertyCallback = c.SDL_CleanupPropertyCallback;
|
pub const CleanupPropertyCallback = c.SDL_CleanupPropertyCallback;
|
||||||
|
|
||||||
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);
|
return @bitCast(c.SDL_SetPointerPropertyWithCleanup(props, name, value, cleanup, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setPointerProperty(props: PropertiesID, name: [*c]const u8, value: ?*anyopaque) bool {
|
pub inline fn setPointerProperty(props: PropertiesID, name: [*c]const u8, value: ?*anyopaque) bool {
|
||||||
return c.SDL_SetPointerProperty(props, name, value);
|
return @bitCast(c.SDL_SetPointerProperty(props, name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setStringProperty(props: PropertiesID, name: [*c]const u8, value: [*c]const u8) bool {
|
pub inline fn setStringProperty(props: PropertiesID, name: [*c]const u8, value: [*c]const u8) bool {
|
||||||
return c.SDL_SetStringProperty(props, name, value);
|
return @bitCast(c.SDL_SetStringProperty(props, name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setNumberProperty(props: PropertiesID, name: [*c]const u8, value: i64) bool {
|
pub inline fn setNumberProperty(props: PropertiesID, name: [*c]const u8, value: i64) bool {
|
||||||
return c.SDL_SetNumberProperty(props, name, value);
|
return @bitCast(c.SDL_SetNumberProperty(props, name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setFloatProperty(props: PropertiesID, name: [*c]const u8, value: f32) bool {
|
pub inline fn setFloatProperty(props: PropertiesID, name: [*c]const u8, value: f32) bool {
|
||||||
return c.SDL_SetFloatProperty(props, name, value);
|
return @bitCast(c.SDL_SetFloatProperty(props, name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setBooleanProperty(props: PropertiesID, name: [*c]const u8, value: bool) bool {
|
pub inline fn setBooleanProperty(props: PropertiesID, name: [*c]const u8, value: bool) bool {
|
||||||
return c.SDL_SetBooleanProperty(props, name, value);
|
return @bitCast(c.SDL_SetBooleanProperty(props, name, @bitCast(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hasProperty(props: PropertiesID, name: [*c]const u8) bool {
|
pub inline fn hasProperty(props: PropertiesID, name: [*c]const u8) bool {
|
||||||
return c.SDL_HasProperty(props, name);
|
return @bitCast(c.SDL_HasProperty(props, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPropertyType(props: PropertiesID, name: [*c]const u8) PropertyType {
|
pub inline fn getPropertyType(props: PropertiesID, name: [*c]const u8) PropertyType {
|
||||||
|
|
@ -83,17 +83,17 @@ pub inline fn getFloatProperty(props: PropertiesID, name: [*c]const u8, default_
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getBooleanProperty(props: PropertiesID, name: [*c]const u8, default_value: bool) bool {
|
pub inline fn getBooleanProperty(props: PropertiesID, name: [*c]const u8, default_value: bool) bool {
|
||||||
return c.SDL_GetBooleanProperty(props, name, default_value);
|
return @bitCast(c.SDL_GetBooleanProperty(props, name, @bitCast(default_value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn clearProperty(props: PropertiesID, name: [*c]const u8) bool {
|
pub inline fn clearProperty(props: PropertiesID, name: [*c]const u8) bool {
|
||||||
return c.SDL_ClearProperty(props, name);
|
return @bitCast(c.SDL_ClearProperty(props, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const EnumeratePropertiesCallback = c.SDL_EnumeratePropertiesCallback;
|
pub const EnumeratePropertiesCallback = c.SDL_EnumeratePropertiesCallback;
|
||||||
|
|
||||||
pub inline fn enumerateProperties(props: PropertiesID, callback: EnumeratePropertiesCallback, userdata: ?*anyopaque) bool {
|
pub inline fn enumerateProperties(props: PropertiesID, callback: EnumeratePropertiesCallback, userdata: ?*anyopaque) bool {
|
||||||
return c.SDL_EnumerateProperties(props, callback, userdata);
|
return @bitCast(c.SDL_EnumerateProperties(props, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyProperties(props: PropertiesID) void {
|
pub inline fn destroyProperties(props: PropertiesID) void {
|
||||||
|
|
|
||||||
20
api/rect.zig
20
api/rect.zig
|
|
@ -26,41 +26,41 @@ pub const FRect = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn hasRectIntersection(A: *const Rect, B: *const Rect) bool {
|
pub inline fn hasRectIntersection(A: *const Rect, B: *const Rect) bool {
|
||||||
return 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 c.SDL_GetRectIntersection(@ptrCast(A), @ptrCast(B), 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 c.SDL_GetRectUnion(@ptrCast(A), @ptrCast(B), 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 c.SDL_GetRectEnclosingPoints(@ptrCast(points), count, @ptrCast(clip), 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 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 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 c.SDL_GetRectIntersectionFloat(@ptrCast(A), @ptrCast(B), 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 c.SDL_GetRectUnionFloat(@ptrCast(A), @ptrCast(B), 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 c.SDL_GetRectEnclosingPointsFloat(@ptrCast(points), count, @ptrCast(clip), 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 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)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
587
api/render.zig
587
api/render.zig
File diff suppressed because it is too large
Load Diff
|
|
@ -5,38 +5,38 @@ pub const PropertiesID = u32;
|
||||||
|
|
||||||
pub const Sensor = opaque {
|
pub const Sensor = opaque {
|
||||||
pub inline fn getSensorProperties(sensor: *Sensor) PropertiesID {
|
pub inline fn getSensorProperties(sensor: *Sensor) PropertiesID {
|
||||||
return c.SDL_GetSensorProperties(sensor);
|
return c.SDL_GetSensorProperties(@ptrCast(sensor));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorName(sensor: *Sensor) [*c]const u8 {
|
pub inline fn getSensorName(sensor: *Sensor) [*c]const u8 {
|
||||||
return c.SDL_GetSensorName(sensor);
|
return c.SDL_GetSensorName(@ptrCast(sensor));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorType(sensor: *Sensor) SensorType {
|
pub inline fn getSensorType(sensor: *Sensor) SensorType {
|
||||||
return @intFromEnum(c.SDL_GetSensorType(sensor));
|
return @intFromEnum(c.SDL_GetSensorType(@ptrCast(sensor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorNonPortableType(sensor: *Sensor) c_int {
|
pub inline fn getSensorNonPortableType(sensor: *Sensor) c_int {
|
||||||
return c.SDL_GetSensorNonPortableType(sensor);
|
return c.SDL_GetSensorNonPortableType(@ptrCast(sensor));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorID(sensor: *Sensor) SensorID {
|
pub inline fn getSensorID(sensor: *Sensor) SensorID {
|
||||||
return c.SDL_GetSensorID(sensor);
|
return c.SDL_GetSensorID(@ptrCast(sensor));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorData(sensor: *Sensor, data: *f32, num_values: c_int) bool {
|
pub inline fn getSensorData(sensor: *Sensor, data: *f32, num_values: c_int) bool {
|
||||||
return c.SDL_GetSensorData(sensor, @ptrCast(data), num_values);
|
return @bitCast(c.SDL_GetSensorData(@ptrCast(sensor), @ptrCast(data), num_values));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn closeSensor(sensor: *Sensor) void {
|
pub inline fn closeSensor(sensor: *Sensor) void {
|
||||||
return c.SDL_CloseSensor(sensor);
|
return c.SDL_CloseSensor(@ptrCast(sensor));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const SensorID = u32;
|
pub const SensorID = u32;
|
||||||
|
|
||||||
pub const SensorType = enum(c_int) {
|
pub const SensorType = enum(c_int) {
|
||||||
sensorInvalid, //Returned for an invalid sensor
|
sensorInvalid = -1, //Returned for an invalid sensor
|
||||||
sensorUnknown, //Unknown sensor type
|
sensorUnknown, //Unknown sensor type
|
||||||
sensorAccel, //Accelerometer
|
sensorAccel, //Accelerometer
|
||||||
sensorGyro, //Gyroscope
|
sensorGyro, //Gyroscope
|
||||||
|
|
@ -48,7 +48,7 @@ pub const SensorType = enum(c_int) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getSensors(count: *c_int) ?*SensorID {
|
pub inline fn getSensors(count: *c_int) ?*SensorID {
|
||||||
return c.SDL_GetSensors(@ptrCast(count));
|
return @ptrCast(c.SDL_GetSensors(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorNameForID(instance_id: SensorID) [*c]const u8 {
|
pub inline fn getSensorNameForID(instance_id: SensorID) [*c]const u8 {
|
||||||
|
|
@ -64,11 +64,11 @@ pub inline fn getSensorNonPortableTypeForID(instance_id: SensorID) c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openSensor(instance_id: SensorID) ?*Sensor {
|
pub inline fn openSensor(instance_id: SensorID) ?*Sensor {
|
||||||
return c.SDL_OpenSensor(instance_id);
|
return @ptrCast(c.SDL_OpenSensor(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSensorFromID(instance_id: SensorID) ?*Sensor {
|
pub inline fn getSensorFromID(instance_id: SensorID) ?*Sensor {
|
||||||
return c.SDL_GetSensorFromID(instance_id);
|
return @ptrCast(c.SDL_GetSensorFromID(instance_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateSensors() void {
|
pub inline fn updateSensors() void {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ pub const GlobFlags = packed struct(u32) {
|
||||||
globCaseinsensitive: bool = false,
|
globCaseinsensitive: bool = false,
|
||||||
pad0: u30 = 0,
|
pad0: u30 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = GlobFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const EnumerateDirectoryCallback = c.SDL_EnumerateDirectoryCallback;
|
pub const EnumerateDirectoryCallback = c.SDL_EnumerateDirectoryCallback;
|
||||||
|
|
@ -45,70 +47,70 @@ pub const StorageInterface = extern struct {
|
||||||
|
|
||||||
pub const Storage = opaque {
|
pub const Storage = opaque {
|
||||||
pub inline fn closeStorage(storage: *Storage) bool {
|
pub inline fn closeStorage(storage: *Storage) bool {
|
||||||
return c.SDL_CloseStorage(storage);
|
return @bitCast(c.SDL_CloseStorage(@ptrCast(storage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn storageReady(storage: *Storage) bool {
|
pub inline fn storageReady(storage: *Storage) bool {
|
||||||
return c.SDL_StorageReady(storage);
|
return @bitCast(c.SDL_StorageReady(@ptrCast(storage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getStorageFileSize(storage: *Storage, path: [*c]const u8, length: *u64) bool {
|
pub inline fn getStorageFileSize(storage: *Storage, path: [*c]const u8, length: *u64) bool {
|
||||||
return c.SDL_GetStorageFileSize(storage, path, @ptrCast(length));
|
return @bitCast(c.SDL_GetStorageFileSize(@ptrCast(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);
|
return @bitCast(c.SDL_ReadStorageFile(@ptrCast(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);
|
return @bitCast(c.SDL_WriteStorageFile(@ptrCast(storage), path, source, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createStorageDirectory(storage: *Storage, path: [*c]const u8) bool {
|
pub inline fn createStorageDirectory(storage: *Storage, path: [*c]const u8) bool {
|
||||||
return c.SDL_CreateStorageDirectory(storage, path);
|
return @bitCast(c.SDL_CreateStorageDirectory(@ptrCast(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);
|
return @bitCast(c.SDL_EnumerateStorageDirectory(@ptrCast(storage), path, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removeStoragePath(storage: *Storage, path: [*c]const u8) bool {
|
pub inline fn removeStoragePath(storage: *Storage, path: [*c]const u8) bool {
|
||||||
return c.SDL_RemoveStoragePath(storage, path);
|
return @bitCast(c.SDL_RemoveStoragePath(@ptrCast(storage), path));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn renameStoragePath(storage: *Storage, oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
pub inline fn renameStoragePath(storage: *Storage, oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
||||||
return c.SDL_RenameStoragePath(storage, oldpath, newpath);
|
return @bitCast(c.SDL_RenameStoragePath(@ptrCast(storage), oldpath, newpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn copyStorageFile(storage: *Storage, oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
pub inline fn copyStorageFile(storage: *Storage, oldpath: [*c]const u8, newpath: [*c]const u8) bool {
|
||||||
return c.SDL_CopyStorageFile(storage, oldpath, newpath);
|
return @bitCast(c.SDL_CopyStorageFile(@ptrCast(storage), oldpath, newpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getStoragePathInfo(storage: *Storage, path: [*c]const u8, info: ?*PathInfo) bool {
|
pub inline fn getStoragePathInfo(storage: *Storage, path: [*c]const u8, info: ?*PathInfo) bool {
|
||||||
return c.SDL_GetStoragePathInfo(storage, path, info);
|
return @bitCast(c.SDL_GetStoragePathInfo(@ptrCast(storage), path, @ptrCast(info)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getStorageSpaceRemaining(storage: *Storage) u64 {
|
pub inline fn getStorageSpaceRemaining(storage: *Storage) u64 {
|
||||||
return c.SDL_GetStorageSpaceRemaining(storage);
|
return c.SDL_GetStorageSpaceRemaining(@ptrCast(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));
|
return c.SDL_GlobStorageDirectory(@ptrCast(storage), path, pattern, @bitCast(flags), @ptrCast(count));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn openTitleStorage(override: [*c]const u8, props: PropertiesID) ?*Storage {
|
pub inline fn openTitleStorage(override: [*c]const u8, props: PropertiesID) ?*Storage {
|
||||||
return c.SDL_OpenTitleStorage(override, props);
|
return @ptrCast(c.SDL_OpenTitleStorage(override, props));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openUserStorage(org: [*c]const u8, app: [*c]const u8, props: PropertiesID) ?*Storage {
|
pub inline fn openUserStorage(org: [*c]const u8, app: [*c]const u8, props: PropertiesID) ?*Storage {
|
||||||
return c.SDL_OpenUserStorage(org, app, props);
|
return @ptrCast(c.SDL_OpenUserStorage(org, app, props));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn openFileStorage(path: [*c]const u8) ?*Storage {
|
pub inline fn openFileStorage(path: [*c]const u8) ?*Storage {
|
||||||
return 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 c.SDL_OpenStorage(@ptrCast(iface), userdata);
|
return @ptrCast(c.SDL_OpenStorage(@ptrCast(iface), userdata));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
203
api/surface.zig
203
api/surface.zig
|
|
@ -2,23 +2,31 @@ const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub const PixelFormat = enum(c_int) {
|
pub const PixelFormat = enum(c_int) {
|
||||||
pixelformatYv12, //Planar mode: Y + V + U (3 planes)
|
pixelformatYv12 = 0x32315659, //Planar mode: Y + V + U (3 planes)
|
||||||
pixelformatIyuv, //Planar mode: Y + U + V (3 planes)
|
pixelformatIyuv = 0x56555949, //Planar mode: Y + U + V (3 planes)
|
||||||
pixelformatYuy2, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
pixelformatYuy2 = 0x32595559, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
||||||
pixelformatUyvy, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
pixelformatUyvy = 0x59565955, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
||||||
pixelformatYvyu, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
pixelformatYvyu = 0x55595659, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
||||||
pixelformatNv12, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatNv12 = 0x3231564e, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatNv21, //Planar mode: Y + V/U interleaved (2 planes)
|
pixelformatNv21 = 0x3132564e, //Planar mode: Y + V/U interleaved (2 planes)
|
||||||
pixelformatP010, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatP010 = 0x30313050, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatExternalOes, //Android video texture format
|
pixelformatExternalOes = 0x2053454f, //Android video texture format
|
||||||
pixelformatMjpg, //Motion JPEG
|
pixelformatMjpg = 0x47504a4d, //Motion JPEG
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const BlendMode = u32;
|
pub const BlendMode = u32;
|
||||||
|
|
||||||
pub const IOStream = opaque {
|
pub const IOStream = opaque {
|
||||||
|
pub inline fn loadSurface_IO(iostream: *IOStream, closeio: bool) ?*Surface {
|
||||||
|
return @ptrCast(c.SDL_LoadSurface_IO(@ptrCast(iostream), @bitCast(closeio)));
|
||||||
|
}
|
||||||
|
|
||||||
pub inline fn loadBMP_IO(iostream: *IOStream, closeio: bool) ?*Surface {
|
pub inline fn loadBMP_IO(iostream: *IOStream, closeio: bool) ?*Surface {
|
||||||
return c.SDL_LoadBMP_IO(iostream, closeio);
|
return @ptrCast(c.SDL_LoadBMP_IO(@ptrCast(iostream), @bitCast(closeio)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn loadPNG_IO(iostream: *IOStream, closeio: bool) ?*Surface {
|
||||||
|
return @ptrCast(c.SDL_LoadPNG_IO(@ptrCast(iostream), @bitCast(closeio)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -44,32 +52,33 @@ pub const Color = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Colorspace = enum(c_int) {
|
pub const Colorspace = enum(c_int) {
|
||||||
colorspaceSrgb, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
colorspaceSrgb = 0x120005a0, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
||||||
colorRangeFull,
|
colorRangeFull,
|
||||||
colorPrimariesBt709,
|
colorPrimariesBt709,
|
||||||
transferCharacteristicsSrgb,
|
transferCharacteristicsSrgb,
|
||||||
matrixCoefficientsIdentity,
|
matrixCoefficientsIdentity,
|
||||||
colorspaceSrgbLinear, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
colorspaceSrgbLinear = 0x12000500, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
||||||
transferCharacteristicsLinear,
|
transferCharacteristicsLinear,
|
||||||
colorspaceHdr10, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
colorspaceHdr10 = 0x12002600, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
||||||
colorPrimariesBt2020,
|
colorPrimariesBt2020,
|
||||||
transferCharacteristicsPq,
|
transferCharacteristicsPq,
|
||||||
colorspaceJpeg, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
colorspaceJpeg = 0x220004c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
||||||
transferCharacteristicsBt601,
|
transferCharacteristicsBt601,
|
||||||
matrixCoefficientsBt601,
|
matrixCoefficientsBt601,
|
||||||
colorspaceBt601Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
colorspaceBt601Limited = 0x211018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
||||||
colorRangeLimited,
|
colorRangeLimited,
|
||||||
colorPrimariesBt601,
|
colorPrimariesBt601,
|
||||||
colorspaceBt601Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
colorspaceBt601Full = 0x221018c6, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
||||||
colorspaceBt709Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
colorspaceBt709Limited = 0x21100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
||||||
transferCharacteristicsBt709,
|
transferCharacteristicsBt709,
|
||||||
matrixCoefficientsBt709,
|
matrixCoefficientsBt709,
|
||||||
colorspaceBt709Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
colorspaceBt709Full = 0x22100421, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
||||||
colorspaceBt2020Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
colorspaceBt2020Limited = 0x21102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
||||||
matrixCoefficientsBt2020Ncl,
|
matrixCoefficientsBt2020Ncl,
|
||||||
colorspaceBt2020Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
colorspaceBt2020Full = 0x22102609, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
|
||||||
colorspaceRgbDefault, //The default colorspace for RGB surfaces if no colorspace is specified
|
|
||||||
colorspaceYuvDefault, //The default colorspace for YUV surfaces if no colorspace is specified
|
pub const colorspaceRgbDefault = .colorspaceSrgb; //The default colorspace for RGB surfaces if no colorspace is specified
|
||||||
|
pub const colorspaceYuvDefault = .colorspaceBt601Limited; //The default colorspace for YUV surfaces if no colorspace is specified
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PropertiesID = u32;
|
pub const PropertiesID = u32;
|
||||||
|
|
@ -81,245 +90,271 @@ pub const SurfaceFlags = packed struct(u32) {
|
||||||
surfaceSimdAligned: bool = false, // Surface uses pixel memory allocated with SDL_aligned_alloc()
|
surfaceSimdAligned: bool = false, // Surface uses pixel memory allocated with SDL_aligned_alloc()
|
||||||
pad0: u27 = 0,
|
pad0: u27 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = SurfaceFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ScaleMode = enum(c_int) {
|
pub const ScaleMode = enum(c_int) {
|
||||||
scalemodeNearest, //nearest pixel sampling
|
scalemodeNearest, //nearest pixel sampling
|
||||||
scalemodeLinear, //linear filtering
|
scalemodeLinear, //linear filtering
|
||||||
|
scalemodePixelart,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const FlipMode = enum(c_int) {
|
pub const FlipMode = packed struct(u32) {
|
||||||
flipNone, //Do not flip
|
flipHorizontal: bool = false, // flip horizontally
|
||||||
flipHorizontal, //flip horizontally
|
flipVertical: bool = false, // flip vertically
|
||||||
flipVertical, //flip vertically
|
pad0: u29 = 0,
|
||||||
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = FlipMode{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Surface = opaque {
|
pub const Surface = opaque {
|
||||||
pub inline fn destroySurface(surface: *Surface) void {
|
pub inline fn destroySurface(surface: *Surface) void {
|
||||||
return c.SDL_DestroySurface(surface);
|
return c.SDL_DestroySurface(@ptrCast(surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceProperties(surface: *Surface) PropertiesID {
|
pub inline fn getSurfaceProperties(surface: *Surface) PropertiesID {
|
||||||
return c.SDL_GetSurfaceProperties(surface);
|
return c.SDL_GetSurfaceProperties(@ptrCast(surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceColorspace(surface: *Surface, colorspace: Colorspace) bool {
|
pub inline fn setSurfaceColorspace(surface: *Surface, colorspace: Colorspace) bool {
|
||||||
return c.SDL_SetSurfaceColorspace(surface, colorspace);
|
return @bitCast(c.SDL_SetSurfaceColorspace(@ptrCast(surface), colorspace));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceColorspace(surface: *Surface) Colorspace {
|
pub inline fn getSurfaceColorspace(surface: *Surface) Colorspace {
|
||||||
return c.SDL_GetSurfaceColorspace(surface);
|
return c.SDL_GetSurfaceColorspace(@ptrCast(surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createSurfacePalette(surface: *Surface) ?*Palette {
|
pub inline fn createSurfacePalette(surface: *Surface) ?*Palette {
|
||||||
return c.SDL_CreateSurfacePalette(surface);
|
return @ptrCast(c.SDL_CreateSurfacePalette(@ptrCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfacePalette(surface: *Surface, palette: ?*Palette) bool {
|
pub inline fn setSurfacePalette(surface: *Surface, palette: ?*Palette) bool {
|
||||||
return c.SDL_SetSurfacePalette(surface, palette);
|
return @bitCast(c.SDL_SetSurfacePalette(@ptrCast(surface), @ptrCast(palette)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfacePalette(surface: *Surface) ?*Palette {
|
pub inline fn getSurfacePalette(surface: *Surface) ?*Palette {
|
||||||
return c.SDL_GetSurfacePalette(surface);
|
return @ptrCast(c.SDL_GetSurfacePalette(@ptrCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn addSurfaceAlternateImage(surface: *Surface, image: ?*Surface) bool {
|
pub inline fn addSurfaceAlternateImage(surface: *Surface, image: ?*Surface) bool {
|
||||||
return c.SDL_AddSurfaceAlternateImage(surface, image);
|
return @bitCast(c.SDL_AddSurfaceAlternateImage(@ptrCast(surface), @ptrCast(image)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn surfaceHasAlternateImages(surface: *Surface) bool {
|
pub inline fn surfaceHasAlternateImages(surface: *Surface) bool {
|
||||||
return c.SDL_SurfaceHasAlternateImages(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][*c]Surface {
|
||||||
return c.SDL_GetSurfaceImages(surface, @ptrCast(count));
|
return c.SDL_GetSurfaceImages(@ptrCast(surface), @ptrCast(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removeSurfaceAlternateImages(surface: *Surface) void {
|
pub inline fn removeSurfaceAlternateImages(surface: *Surface) void {
|
||||||
return c.SDL_RemoveSurfaceAlternateImages(surface);
|
return c.SDL_RemoveSurfaceAlternateImages(@ptrCast(surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn lockSurface(surface: *Surface) bool {
|
pub inline fn lockSurface(surface: *Surface) bool {
|
||||||
return c.SDL_LockSurface(surface);
|
return @bitCast(c.SDL_LockSurface(@ptrCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn unlockSurface(surface: *Surface) void {
|
pub inline fn unlockSurface(surface: *Surface) void {
|
||||||
return c.SDL_UnlockSurface(surface);
|
return c.SDL_UnlockSurface(@ptrCast(surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn saveBMP_IO(surface: *Surface, dst: ?*IOStream, closeio: bool) bool {
|
pub inline fn saveBMP_IO(surface: *Surface, dst: ?*IOStream, closeio: bool) bool {
|
||||||
return c.SDL_SaveBMP_IO(surface, dst, closeio);
|
return @bitCast(c.SDL_SaveBMP_IO(@ptrCast(surface), @ptrCast(dst), @bitCast(closeio)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn saveBMP(surface: *Surface, file: [*c]const u8) bool {
|
pub inline fn saveBMP(surface: *Surface, file: [*c]const u8) bool {
|
||||||
return c.SDL_SaveBMP(surface, file);
|
return @bitCast(c.SDL_SaveBMP(@ptrCast(surface), file));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn savePNG_IO(surface: *Surface, dst: ?*IOStream, closeio: bool) bool {
|
||||||
|
return @bitCast(c.SDL_SavePNG_IO(@ptrCast(surface), @ptrCast(dst), @bitCast(closeio)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn savePNG(surface: *Surface, file: [*c]const u8) bool {
|
||||||
|
return @bitCast(c.SDL_SavePNG(@ptrCast(surface), file));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceRLE(surface: *Surface, enabled: bool) bool {
|
pub inline fn setSurfaceRLE(surface: *Surface, enabled: bool) bool {
|
||||||
return c.SDL_SetSurfaceRLE(surface, enabled);
|
return @bitCast(c.SDL_SetSurfaceRLE(@ptrCast(surface), @bitCast(enabled)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn surfaceHasRLE(surface: *Surface) bool {
|
pub inline fn surfaceHasRLE(surface: *Surface) bool {
|
||||||
return c.SDL_SurfaceHasRLE(surface);
|
return @bitCast(c.SDL_SurfaceHasRLE(@ptrCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceColorKey(surface: *Surface, enabled: bool, key: u32) bool {
|
pub inline fn setSurfaceColorKey(surface: *Surface, enabled: bool, key: u32) bool {
|
||||||
return c.SDL_SetSurfaceColorKey(surface, enabled, key);
|
return @bitCast(c.SDL_SetSurfaceColorKey(@ptrCast(surface), @bitCast(enabled), key));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn surfaceHasColorKey(surface: *Surface) bool {
|
pub inline fn surfaceHasColorKey(surface: *Surface) bool {
|
||||||
return c.SDL_SurfaceHasColorKey(surface);
|
return @bitCast(c.SDL_SurfaceHasColorKey(@ptrCast(surface)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceColorKey(surface: *Surface, key: *u32) bool {
|
pub inline fn getSurfaceColorKey(surface: *Surface, key: *u32) bool {
|
||||||
return c.SDL_GetSurfaceColorKey(surface, @ptrCast(key));
|
return @bitCast(c.SDL_GetSurfaceColorKey(@ptrCast(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);
|
return @bitCast(c.SDL_SetSurfaceColorMod(@ptrCast(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);
|
return @bitCast(c.SDL_GetSurfaceColorMod(@ptrCast(surface), r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceAlphaMod(surface: *Surface, alpha: u8) bool {
|
pub inline fn setSurfaceAlphaMod(surface: *Surface, alpha: u8) bool {
|
||||||
return c.SDL_SetSurfaceAlphaMod(surface, alpha);
|
return @bitCast(c.SDL_SetSurfaceAlphaMod(@ptrCast(surface), alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceAlphaMod(surface: *Surface, alpha: [*c]u8) bool {
|
pub inline fn getSurfaceAlphaMod(surface: *Surface, alpha: [*c]u8) bool {
|
||||||
return c.SDL_GetSurfaceAlphaMod(surface, alpha);
|
return @bitCast(c.SDL_GetSurfaceAlphaMod(@ptrCast(surface), alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setSurfaceBlendMode(surface: *Surface, blendMode: BlendMode) bool {
|
pub inline fn setSurfaceBlendMode(surface: *Surface, blendMode: BlendMode) bool {
|
||||||
return c.SDL_SetSurfaceBlendMode(surface, @intFromEnum(blendMode));
|
return @bitCast(c.SDL_SetSurfaceBlendMode(@ptrCast(surface), @intFromEnum(blendMode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceBlendMode(surface: *Surface, blendMode: ?*BlendMode) bool {
|
pub inline fn getSurfaceBlendMode(surface: *Surface, blendMode: ?*BlendMode) bool {
|
||||||
return c.SDL_GetSurfaceBlendMode(surface, @intFromEnum(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 c.SDL_SetSurfaceClipRect(surface, @ptrCast(rect));
|
return @bitCast(c.SDL_SetSurfaceClipRect(@ptrCast(surface), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getSurfaceClipRect(surface: *Surface, rect: ?*Rect) bool {
|
pub inline fn getSurfaceClipRect(surface: *Surface, rect: ?*Rect) bool {
|
||||||
return c.SDL_GetSurfaceClipRect(surface, rect);
|
return @bitCast(c.SDL_GetSurfaceClipRect(@ptrCast(surface), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn flipSurface(surface: *Surface, flip: FlipMode) bool {
|
pub inline fn flipSurface(surface: *Surface, flip: FlipMode) bool {
|
||||||
return c.SDL_FlipSurface(surface, @intFromEnum(flip));
|
return @bitCast(c.SDL_FlipSurface(@ptrCast(surface), @intFromEnum(flip)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn rotateSurface(surface: *Surface, angle: f32) ?*Surface {
|
||||||
|
return @ptrCast(c.SDL_RotateSurface(@ptrCast(surface), angle));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn duplicateSurface(surface: *Surface) ?*Surface {
|
pub inline fn duplicateSurface(surface: *Surface) ?*Surface {
|
||||||
return c.SDL_DuplicateSurface(surface);
|
return @ptrCast(c.SDL_DuplicateSurface(@ptrCast(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));
|
return @ptrCast(c.SDL_ScaleSurface(@ptrCast(surface), width, height, @intFromEnum(scaleMode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn convertSurface(surface: *Surface, format: PixelFormat) ?*Surface {
|
pub inline fn convertSurface(surface: *Surface, format: PixelFormat) ?*Surface {
|
||||||
return c.SDL_ConvertSurface(surface, @bitCast(format));
|
return @ptrCast(c.SDL_ConvertSurface(@ptrCast(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);
|
return @ptrCast(c.SDL_ConvertSurfaceAndColorspace(@ptrCast(surface), @bitCast(format), @ptrCast(palette), colorspace, props));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn premultiplySurfaceAlpha(surface: *Surface, linear: bool) bool {
|
pub inline fn premultiplySurfaceAlpha(surface: *Surface, linear: bool) bool {
|
||||||
return c.SDL_PremultiplySurfaceAlpha(surface, linear);
|
return @bitCast(c.SDL_PremultiplySurfaceAlpha(@ptrCast(surface), @bitCast(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);
|
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 c.SDL_FillSurfaceRect(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 c.SDL_FillSurfaceRects(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 c.SDL_BlitSurface(surface, @ptrCast(srcrect), 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 c.SDL_BlitSurfaceUnchecked(surface, @ptrCast(srcrect), 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 c.SDL_BlitSurfaceScaled(surface, @ptrCast(srcrect), 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 c.SDL_BlitSurfaceUncheckedScaled(surface, @ptrCast(srcrect), 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 c.SDL_StretchSurface(surface, @ptrCast(srcrect), 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 c.SDL_BlitSurfaceTiled(surface, @ptrCast(srcrect), 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 c.SDL_BlitSurfaceTiledWithScale(surface, @ptrCast(srcrect), scale, @intFromEnum(scaleMode), 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 c.SDL_BlitSurface9Grid(surface, @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @intFromEnum(scaleMode), 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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
return c.SDL_MapSurfaceRGB(@ptrCast(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);
|
return c.SDL_MapSurfaceRGBA(@ptrCast(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);
|
return @bitCast(c.SDL_ReadSurfacePixel(@ptrCast(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));
|
return @bitCast(c.SDL_ReadSurfacePixelFloat(@ptrCast(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);
|
return @bitCast(c.SDL_WriteSurfacePixel(@ptrCast(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);
|
return @bitCast(c.SDL_WriteSurfacePixelFloat(@ptrCast(surface), x, y, r, g, b, a));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn createSurface(width: c_int, height: c_int, format: PixelFormat) ?*Surface {
|
pub inline fn createSurface(width: c_int, height: c_int, format: PixelFormat) ?*Surface {
|
||||||
return c.SDL_CreateSurface(width, height, @bitCast(format));
|
return @ptrCast(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);
|
return @ptrCast(c.SDL_CreateSurfaceFrom(width, height, @bitCast(format), pixels, pitch));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn loadSurface(file: [*c]const u8) ?*Surface {
|
||||||
|
return @ptrCast(c.SDL_LoadSurface(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn loadBMP(file: [*c]const u8) ?*Surface {
|
pub inline fn loadBMP(file: [*c]const u8) ?*Surface {
|
||||||
return c.SDL_LoadBMP(file);
|
return @ptrCast(c.SDL_LoadBMP(file));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn loadPNG(file: [*c]const u8) ?*Surface {
|
||||||
|
return @ptrCast(c.SDL_LoadPNG(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);
|
return @bitCast(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);
|
return @bitCast(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);
|
return @bitCast(c.SDL_PremultiplyAlpha(width, height, @bitCast(src_format), src, src_pitch, @bitCast(dst_format), dst, dst_pitch, @bitCast(linear)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ pub const DisplayID = u32;
|
||||||
|
|
||||||
pub const Window = opaque {
|
pub const Window = opaque {
|
||||||
pub inline fn setiOSAnimationCallback(window: *Window, interval: c_int, callback: iOSAnimationCallback, callbackParam: ?*anyopaque) bool {
|
pub inline fn setiOSAnimationCallback(window: *Window, interval: c_int, callback: iOSAnimationCallback, callbackParam: ?*anyopaque) bool {
|
||||||
return c.SDL_SetiOSAnimationCallback(window, interval, callback, callbackParam);
|
return @bitCast(c.SDL_SetiOSAnimationCallback(@ptrCast(window), interval, callback, callbackParam));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ pub inline fn getDirect3D9AdapterIndex(displayID: DisplayID) c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDXGIOutputInfo(displayID: DisplayID, adapterIndex: *c_int, outputIndex: *c_int) bool {
|
pub inline fn getDXGIOutputInfo(displayID: DisplayID, adapterIndex: *c_int, outputIndex: *c_int) bool {
|
||||||
return c.SDL_GetDXGIOutputInfo(displayID, @ptrCast(adapterIndex), @ptrCast(outputIndex));
|
return @bitCast(c.SDL_GetDXGIOutputInfo(displayID, @ptrCast(adapterIndex), @ptrCast(outputIndex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const X11EventHook = c.SDL_X11EventHook;
|
pub const X11EventHook = c.SDL_X11EventHook;
|
||||||
|
|
@ -32,17 +32,17 @@ pub inline fn setX11EventHook(callback: X11EventHook, userdata: ?*anyopaque) voi
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setLinuxThreadPriority(threadID: i64, priority: c_int) bool {
|
pub inline fn setLinuxThreadPriority(threadID: i64, priority: c_int) bool {
|
||||||
return c.SDL_SetLinuxThreadPriority(threadID, priority);
|
return @bitCast(c.SDL_SetLinuxThreadPriority(threadID, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setLinuxThreadPriorityAndPolicy(threadID: i64, sdlPriority: c_int, schedPolicy: c_int) bool {
|
pub inline fn setLinuxThreadPriorityAndPolicy(threadID: i64, sdlPriority: c_int, schedPolicy: c_int) bool {
|
||||||
return c.SDL_SetLinuxThreadPriorityAndPolicy(threadID, sdlPriority, schedPolicy);
|
return @bitCast(c.SDL_SetLinuxThreadPriorityAndPolicy(threadID, sdlPriority, schedPolicy));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const iOSAnimationCallback = c.SDL_iOSAnimationCallback;
|
pub const iOSAnimationCallback = c.SDL_iOSAnimationCallback;
|
||||||
|
|
||||||
pub inline fn setiOSEventPump(enabled: bool) void {
|
pub inline fn setiOSEventPump(enabled: bool) void {
|
||||||
return c.SDL_SetiOSEventPump(enabled);
|
return c.SDL_SetiOSEventPump(@bitCast(enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getAndroidJNIEnv() ?*anyopaque {
|
pub inline fn getAndroidJNIEnv() ?*anyopaque {
|
||||||
|
|
@ -58,11 +58,11 @@ pub inline fn getAndroidSDKVersion() c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isChromebook() bool {
|
pub inline fn isChromebook() bool {
|
||||||
return c.SDL_IsChromebook();
|
return @bitCast(c.SDL_IsChromebook());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isDeXMode() bool {
|
pub inline fn isDeXMode() bool {
|
||||||
return c.SDL_IsDeXMode();
|
return @bitCast(c.SDL_IsDeXMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn sendAndroidBackButton() void {
|
pub inline fn sendAndroidBackButton() void {
|
||||||
|
|
@ -88,23 +88,23 @@ pub inline fn getAndroidCachePath() [*c]const u8 {
|
||||||
pub const RequestAndroidPermissionCallback = c.SDL_RequestAndroidPermissionCallback;
|
pub const RequestAndroidPermissionCallback = c.SDL_RequestAndroidPermissionCallback;
|
||||||
|
|
||||||
pub inline fn requestAndroidPermission(permission: [*c]const u8, cb: RequestAndroidPermissionCallback, userdata: ?*anyopaque) bool {
|
pub inline fn requestAndroidPermission(permission: [*c]const u8, cb: RequestAndroidPermissionCallback, userdata: ?*anyopaque) bool {
|
||||||
return c.SDL_RequestAndroidPermission(permission, cb, userdata);
|
return @bitCast(c.SDL_RequestAndroidPermission(permission, cb, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showAndroidToast(message: [*c]const u8, duration: c_int, gravity: c_int, xoffset: c_int, yoffset: c_int) bool {
|
pub inline fn showAndroidToast(message: [*c]const u8, duration: c_int, gravity: c_int, xoffset: c_int, yoffset: c_int) bool {
|
||||||
return c.SDL_ShowAndroidToast(message, duration, gravity, xoffset, yoffset);
|
return @bitCast(c.SDL_ShowAndroidToast(message, duration, gravity, xoffset, yoffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn sendAndroidMessage(command: u32, param: c_int) bool {
|
pub inline fn sendAndroidMessage(command: u32, param: c_int) bool {
|
||||||
return c.SDL_SendAndroidMessage(command, param);
|
return @bitCast(c.SDL_SendAndroidMessage(command, param));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isTablet() bool {
|
pub inline fn isTablet() bool {
|
||||||
return c.SDL_IsTablet();
|
return @bitCast(c.SDL_IsTablet());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn isTV() bool {
|
pub inline fn isTV() bool {
|
||||||
return c.SDL_IsTV();
|
return @bitCast(c.SDL_IsTV());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const Sandbox = enum(c_int) {
|
pub const Sandbox = enum(c_int) {
|
||||||
|
|
@ -151,9 +151,9 @@ pub const XTaskQueueHandle = *anyopaque;
|
||||||
pub const XUserHandle = *anyopaque;
|
pub const XUserHandle = *anyopaque;
|
||||||
|
|
||||||
pub inline fn getGDKTaskQueue(outTaskQueue: [*c]XTaskQueueHandle) bool {
|
pub inline fn getGDKTaskQueue(outTaskQueue: [*c]XTaskQueueHandle) bool {
|
||||||
return c.SDL_GetGDKTaskQueue(outTaskQueue);
|
return @bitCast(c.SDL_GetGDKTaskQueue(outTaskQueue));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGDKDefaultUser(outUserHandle: [*c]XUserHandle) bool {
|
pub inline fn getGDKDefaultUser(outUserHandle: [*c]XUserHandle) bool {
|
||||||
return c.SDL_GetGDKDefaultUser(outUserHandle);
|
return @bitCast(c.SDL_GetGDKDefaultUser(outUserHandle));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
api/time.zig
18
api/time.zig
|
|
@ -16,30 +16,30 @@ pub const DateTime = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DateFormat = enum(c_int) {
|
pub const DateFormat = enum(c_int) {
|
||||||
dateFormatYyyymmdd, //Year/Month/Day
|
dateFormatYyyymmdd = 0, //Year/Month/Day
|
||||||
dateFormatDdmmyyyy, //Day/Month/Year
|
dateFormatDdmmyyyy = 1, //Day/Month/Year
|
||||||
dateFormatMmddyyyy, //Month/Day/Year
|
dateFormatMmddyyyy = 2, //Month/Day/Year
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TimeFormat = enum(c_int) {
|
pub const TimeFormat = enum(c_int) {
|
||||||
timeFormat24hr, //24 hour time
|
timeFormat24hr = 0, //24 hour time
|
||||||
timeFormat12hr, //12 hour time
|
timeFormat12hr = 1, //12 hour time
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getDateTimeLocalePreferences(dateFormat: ?*DateFormat, timeFormat: ?*TimeFormat) bool {
|
pub inline fn getDateTimeLocalePreferences(dateFormat: ?*DateFormat, timeFormat: ?*TimeFormat) bool {
|
||||||
return c.SDL_GetDateTimeLocalePreferences(@bitCast(dateFormat), @bitCast(timeFormat));
|
return @bitCast(c.SDL_GetDateTimeLocalePreferences(@ptrCast(dateFormat), @ptrCast(timeFormat)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getCurrentTime(ticks: ?*Time) bool {
|
pub inline fn getCurrentTime(ticks: ?*Time) bool {
|
||||||
return c.SDL_GetCurrentTime(ticks);
|
return @bitCast(c.SDL_GetCurrentTime(@ptrCast(ticks)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn timeToDateTime(ticks: Time, dt: ?*DateTime, localTime: bool) bool {
|
pub inline fn timeToDateTime(ticks: Time, dt: ?*DateTime, localTime: bool) bool {
|
||||||
return c.SDL_TimeToDateTime(ticks, dt, 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 c.SDL_DateTimeToTime(@ptrCast(dt), ticks);
|
return @bitCast(c.SDL_DateTimeToTime(@ptrCast(dt), @ptrCast(ticks)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn timeToWindows(ticks: Time, dwLowDateTime: *u32, dwHighDateTime: *u32) void {
|
pub inline fn timeToWindows(ticks: Time, dwLowDateTime: *u32, dwHighDateTime: *u32) void {
|
||||||
|
|
|
||||||
|
|
@ -44,5 +44,5 @@ pub inline fn addTimerNS(interval: u64, callback: NSTimerCallback, userdata: ?*a
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn removeTimer(id: TimerID) bool {
|
pub inline fn removeTimer(id: TimerID) bool {
|
||||||
return c.SDL_RemoveTimer(id);
|
return @bitCast(c.SDL_RemoveTimer(id));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ pub const Finger = extern struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getTouchDevices(count: *c_int) ?*TouchID {
|
pub inline fn getTouchDevices(count: *c_int) ?*TouchID {
|
||||||
return c.SDL_GetTouchDevices(@ptrCast(count));
|
return @ptrCast(c.SDL_GetTouchDevices(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getTouchDeviceName(touchID: TouchID) [*c]const u8 {
|
pub inline fn getTouchDeviceName(touchID: TouchID) [*c]const u8 {
|
||||||
|
|
|
||||||
226
api/video.zig
226
api/video.zig
|
|
@ -2,16 +2,16 @@ const std = @import("std");
|
||||||
pub const c = @import("c.zig").c;
|
pub const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub const PixelFormat = enum(c_int) {
|
pub const PixelFormat = enum(c_int) {
|
||||||
pixelformatYv12, //Planar mode: Y + V + U (3 planes)
|
pixelformatYv12 = 0x32315659, //Planar mode: Y + V + U (3 planes)
|
||||||
pixelformatIyuv, //Planar mode: Y + U + V (3 planes)
|
pixelformatIyuv = 0x56555949, //Planar mode: Y + U + V (3 planes)
|
||||||
pixelformatYuy2, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
pixelformatYuy2 = 0x32595559, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
||||||
pixelformatUyvy, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
pixelformatUyvy = 0x59565955, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
||||||
pixelformatYvyu, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
pixelformatYvyu = 0x55595659, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
||||||
pixelformatNv12, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatNv12 = 0x3231564e, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatNv21, //Planar mode: Y + V/U interleaved (2 planes)
|
pixelformatNv21 = 0x3132564e, //Planar mode: Y + V/U interleaved (2 planes)
|
||||||
pixelformatP010, //Planar mode: Y + U/V interleaved (2 planes)
|
pixelformatP010 = 0x30313050, //Planar mode: Y + U/V interleaved (2 planes)
|
||||||
pixelformatExternalOes, //Android video texture format
|
pixelformatExternalOes = 0x2053454f, //Android video texture format
|
||||||
pixelformatMjpg, //Motion JPEG
|
pixelformatMjpg = 0x47504a4d, //Motion JPEG
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Point = extern struct {
|
pub const Point = extern struct {
|
||||||
|
|
@ -66,267 +66,287 @@ pub const DisplayOrientation = enum(c_int) {
|
||||||
|
|
||||||
pub const Window = opaque {
|
pub const Window = opaque {
|
||||||
pub inline fn getDisplayForWindow(window: *Window) DisplayID {
|
pub inline fn getDisplayForWindow(window: *Window) DisplayID {
|
||||||
return c.SDL_GetDisplayForWindow(window);
|
return c.SDL_GetDisplayForWindow(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowPixelDensity(window: *Window) f32 {
|
pub inline fn getWindowPixelDensity(window: *Window) f32 {
|
||||||
return c.SDL_GetWindowPixelDensity(window);
|
return c.SDL_GetWindowPixelDensity(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowDisplayScale(window: *Window) f32 {
|
pub inline fn getWindowDisplayScale(window: *Window) f32 {
|
||||||
return c.SDL_GetWindowDisplayScale(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 c.SDL_SetWindowFullscreenMode(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(window));
|
return @ptrCast(c.SDL_GetWindowFullscreenMode(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowICCProfile(window: *Window, size: *usize) ?*anyopaque {
|
pub inline fn getWindowICCProfile(window: *Window, size: *usize) ?*anyopaque {
|
||||||
return c.SDL_GetWindowICCProfile(window, @ptrCast(size));
|
return c.SDL_GetWindowICCProfile(@ptrCast(window), @ptrCast(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowPixelFormat(window: *Window) PixelFormat {
|
pub inline fn getWindowPixelFormat(window: *Window) PixelFormat {
|
||||||
return @bitCast(c.SDL_GetWindowPixelFormat(window));
|
return @bitCast(c.SDL_GetWindowPixelFormat(@ptrCast(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));
|
return @ptrCast(c.SDL_CreatePopupWindow(@ptrCast(window), offset_x, offset_y, w, h, @bitCast(flags)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowID(window: *Window) WindowID {
|
pub inline fn getWindowID(window: *Window) WindowID {
|
||||||
return c.SDL_GetWindowID(window);
|
return c.SDL_GetWindowID(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowParent(window: *Window) ?*Window {
|
pub inline fn getWindowParent(window: *Window) ?*Window {
|
||||||
return c.SDL_GetWindowParent(window);
|
return @ptrCast(c.SDL_GetWindowParent(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowProperties(window: *Window) PropertiesID {
|
pub inline fn getWindowProperties(window: *Window) PropertiesID {
|
||||||
return c.SDL_GetWindowProperties(window);
|
return c.SDL_GetWindowProperties(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFlags(window: *Window) WindowFlags {
|
pub inline fn getWindowFlags(window: *Window) WindowFlags {
|
||||||
return @bitCast(c.SDL_GetWindowFlags(window));
|
return @bitCast(c.SDL_GetWindowFlags(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowTitle(window: *Window, title: [*c]const u8) bool {
|
pub inline fn setWindowTitle(window: *Window, title: [*c]const u8) bool {
|
||||||
return c.SDL_SetWindowTitle(window, title);
|
return @bitCast(c.SDL_SetWindowTitle(@ptrCast(window), title));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowTitle(window: *Window) [*c]const u8 {
|
pub inline fn getWindowTitle(window: *Window) [*c]const u8 {
|
||||||
return c.SDL_GetWindowTitle(window);
|
return c.SDL_GetWindowTitle(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowIcon(window: *Window, icon: ?*Surface) bool {
|
pub inline fn setWindowIcon(window: *Window, icon: ?*Surface) bool {
|
||||||
return c.SDL_SetWindowIcon(window, icon);
|
return @bitCast(c.SDL_SetWindowIcon(@ptrCast(window), @ptrCast(icon)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowPosition(window: *Window, x: c_int, y: c_int) bool {
|
pub inline fn setWindowPosition(window: *Window, x: c_int, y: c_int) bool {
|
||||||
return c.SDL_SetWindowPosition(window, x, y);
|
return @bitCast(c.SDL_SetWindowPosition(@ptrCast(window), x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowPosition(window: *Window, x: *c_int, y: *c_int) bool {
|
pub inline fn getWindowPosition(window: *Window, x: *c_int, y: *c_int) bool {
|
||||||
return c.SDL_GetWindowPosition(window, @ptrCast(x), @ptrCast(y));
|
return @bitCast(c.SDL_GetWindowPosition(@ptrCast(window), @ptrCast(x), @ptrCast(y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowSize(window: *Window, w: c_int, h: c_int) bool {
|
pub inline fn setWindowSize(window: *Window, w: c_int, h: c_int) bool {
|
||||||
return c.SDL_SetWindowSize(window, w, h);
|
return @bitCast(c.SDL_SetWindowSize(@ptrCast(window), w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSize(window: *Window, w: *c_int, h: *c_int) bool {
|
pub inline fn getWindowSize(window: *Window, w: *c_int, h: *c_int) bool {
|
||||||
return c.SDL_GetWindowSize(window, @ptrCast(w), @ptrCast(h));
|
return @bitCast(c.SDL_GetWindowSize(@ptrCast(window), @ptrCast(w), @ptrCast(h)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSafeArea(window: *Window, rect: ?*Rect) bool {
|
pub inline fn getWindowSafeArea(window: *Window, rect: ?*Rect) bool {
|
||||||
return c.SDL_GetWindowSafeArea(window, rect);
|
return @bitCast(c.SDL_GetWindowSafeArea(@ptrCast(window), @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowAspectRatio(window: *Window, min_aspect: f32, max_aspect: f32) bool {
|
pub inline fn setWindowAspectRatio(window: *Window, min_aspect: f32, max_aspect: f32) bool {
|
||||||
return c.SDL_SetWindowAspectRatio(window, min_aspect, max_aspect);
|
return @bitCast(c.SDL_SetWindowAspectRatio(@ptrCast(window), min_aspect, max_aspect));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowAspectRatio(window: *Window, min_aspect: *f32, max_aspect: *f32) bool {
|
pub inline fn getWindowAspectRatio(window: *Window, min_aspect: *f32, max_aspect: *f32) bool {
|
||||||
return c.SDL_GetWindowAspectRatio(window, @ptrCast(min_aspect), @ptrCast(max_aspect));
|
return @bitCast(c.SDL_GetWindowAspectRatio(@ptrCast(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));
|
return @bitCast(c.SDL_GetWindowBordersSize(@ptrCast(window), @ptrCast(top), @ptrCast(left), @ptrCast(bottom), @ptrCast(right)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSizeInPixels(window: *Window, w: *c_int, h: *c_int) bool {
|
pub inline fn getWindowSizeInPixels(window: *Window, w: *c_int, h: *c_int) bool {
|
||||||
return c.SDL_GetWindowSizeInPixels(window, @ptrCast(w), @ptrCast(h));
|
return @bitCast(c.SDL_GetWindowSizeInPixels(@ptrCast(window), @ptrCast(w), @ptrCast(h)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowMinimumSize(window: *Window, min_w: c_int, min_h: c_int) bool {
|
pub inline fn setWindowMinimumSize(window: *Window, min_w: c_int, min_h: c_int) bool {
|
||||||
return c.SDL_SetWindowMinimumSize(window, min_w, min_h);
|
return @bitCast(c.SDL_SetWindowMinimumSize(@ptrCast(window), min_w, min_h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowMinimumSize(window: *Window, w: *c_int, h: *c_int) bool {
|
pub inline fn getWindowMinimumSize(window: *Window, w: *c_int, h: *c_int) bool {
|
||||||
return c.SDL_GetWindowMinimumSize(window, @ptrCast(w), @ptrCast(h));
|
return @bitCast(c.SDL_GetWindowMinimumSize(@ptrCast(window), @ptrCast(w), @ptrCast(h)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowMaximumSize(window: *Window, max_w: c_int, max_h: c_int) bool {
|
pub inline fn setWindowMaximumSize(window: *Window, max_w: c_int, max_h: c_int) bool {
|
||||||
return c.SDL_SetWindowMaximumSize(window, max_w, max_h);
|
return @bitCast(c.SDL_SetWindowMaximumSize(@ptrCast(window), max_w, max_h));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowMaximumSize(window: *Window, w: *c_int, h: *c_int) bool {
|
pub inline fn getWindowMaximumSize(window: *Window, w: *c_int, h: *c_int) bool {
|
||||||
return c.SDL_GetWindowMaximumSize(window, @ptrCast(w), @ptrCast(h));
|
return @bitCast(c.SDL_GetWindowMaximumSize(@ptrCast(window), @ptrCast(w), @ptrCast(h)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowBordered(window: *Window, bordered: bool) bool {
|
pub inline fn setWindowBordered(window: *Window, bordered: bool) bool {
|
||||||
return c.SDL_SetWindowBordered(window, bordered);
|
return @bitCast(c.SDL_SetWindowBordered(@ptrCast(window), @bitCast(bordered)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowResizable(window: *Window, resizable: bool) bool {
|
pub inline fn setWindowResizable(window: *Window, resizable: bool) bool {
|
||||||
return c.SDL_SetWindowResizable(window, resizable);
|
return @bitCast(c.SDL_SetWindowResizable(@ptrCast(window), @bitCast(resizable)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowAlwaysOnTop(window: *Window, on_top: bool) bool {
|
pub inline fn setWindowAlwaysOnTop(window: *Window, on_top: bool) bool {
|
||||||
return c.SDL_SetWindowAlwaysOnTop(window, on_top);
|
return @bitCast(c.SDL_SetWindowAlwaysOnTop(@ptrCast(window), @bitCast(on_top)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn setWindowFillDocument(window: *Window, fill: bool) bool {
|
||||||
|
return @bitCast(c.SDL_SetWindowFillDocument(@ptrCast(window), @bitCast(fill)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showWindow(window: *Window) bool {
|
pub inline fn showWindow(window: *Window) bool {
|
||||||
return c.SDL_ShowWindow(window);
|
return @bitCast(c.SDL_ShowWindow(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn hideWindow(window: *Window) bool {
|
pub inline fn hideWindow(window: *Window) bool {
|
||||||
return c.SDL_HideWindow(window);
|
return @bitCast(c.SDL_HideWindow(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn raiseWindow(window: *Window) bool {
|
pub inline fn raiseWindow(window: *Window) bool {
|
||||||
return c.SDL_RaiseWindow(window);
|
return @bitCast(c.SDL_RaiseWindow(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn maximizeWindow(window: *Window) bool {
|
pub inline fn maximizeWindow(window: *Window) bool {
|
||||||
return c.SDL_MaximizeWindow(window);
|
return @bitCast(c.SDL_MaximizeWindow(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn minimizeWindow(window: *Window) bool {
|
pub inline fn minimizeWindow(window: *Window) bool {
|
||||||
return c.SDL_MinimizeWindow(window);
|
return @bitCast(c.SDL_MinimizeWindow(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn restoreWindow(window: *Window) bool {
|
pub inline fn restoreWindow(window: *Window) bool {
|
||||||
return c.SDL_RestoreWindow(window);
|
return @bitCast(c.SDL_RestoreWindow(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowFullscreen(window: *Window, fullscreen: bool) bool {
|
pub inline fn setWindowFullscreen(window: *Window, fullscreen: bool) bool {
|
||||||
return c.SDL_SetWindowFullscreen(window, fullscreen);
|
return @bitCast(c.SDL_SetWindowFullscreen(@ptrCast(window), @bitCast(fullscreen)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn syncWindow(window: *Window) bool {
|
pub inline fn syncWindow(window: *Window) bool {
|
||||||
return c.SDL_SyncWindow(window);
|
return @bitCast(c.SDL_SyncWindow(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn windowHasSurface(window: *Window) bool {
|
pub inline fn windowHasSurface(window: *Window) bool {
|
||||||
return c.SDL_WindowHasSurface(window);
|
return @bitCast(c.SDL_WindowHasSurface(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSurface(window: *Window) ?*Surface {
|
pub inline fn getWindowSurface(window: *Window) ?*Surface {
|
||||||
return c.SDL_GetWindowSurface(window);
|
return @ptrCast(c.SDL_GetWindowSurface(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowSurfaceVSync(window: *Window, vsync: c_int) bool {
|
pub inline fn setWindowSurfaceVSync(window: *Window, vsync: c_int) bool {
|
||||||
return c.SDL_SetWindowSurfaceVSync(window, vsync);
|
return @bitCast(c.SDL_SetWindowSurfaceVSync(@ptrCast(window), vsync));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowSurfaceVSync(window: *Window, vsync: *c_int) bool {
|
pub inline fn getWindowSurfaceVSync(window: *Window, vsync: *c_int) bool {
|
||||||
return c.SDL_GetWindowSurfaceVSync(window, @ptrCast(vsync));
|
return @bitCast(c.SDL_GetWindowSurfaceVSync(@ptrCast(window), @ptrCast(vsync)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn updateWindowSurface(window: *Window) bool {
|
pub inline fn updateWindowSurface(window: *Window) bool {
|
||||||
return c.SDL_UpdateWindowSurface(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 c.SDL_UpdateWindowSurfaceRects(window, @ptrCast(rects), numrects);
|
return @bitCast(c.SDL_UpdateWindowSurfaceRects(@ptrCast(window), @ptrCast(rects), numrects));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyWindowSurface(window: *Window) bool {
|
pub inline fn destroyWindowSurface(window: *Window) bool {
|
||||||
return c.SDL_DestroyWindowSurface(window);
|
return @bitCast(c.SDL_DestroyWindowSurface(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowKeyboardGrab(window: *Window, grabbed: bool) bool {
|
pub inline fn setWindowKeyboardGrab(window: *Window, grabbed: bool) bool {
|
||||||
return c.SDL_SetWindowKeyboardGrab(window, grabbed);
|
return @bitCast(c.SDL_SetWindowKeyboardGrab(@ptrCast(window), @bitCast(grabbed)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowMouseGrab(window: *Window, grabbed: bool) bool {
|
pub inline fn setWindowMouseGrab(window: *Window, grabbed: bool) bool {
|
||||||
return c.SDL_SetWindowMouseGrab(window, grabbed);
|
return @bitCast(c.SDL_SetWindowMouseGrab(@ptrCast(window), @bitCast(grabbed)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowKeyboardGrab(window: *Window) bool {
|
pub inline fn getWindowKeyboardGrab(window: *Window) bool {
|
||||||
return c.SDL_GetWindowKeyboardGrab(window);
|
return @bitCast(c.SDL_GetWindowKeyboardGrab(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowMouseGrab(window: *Window) bool {
|
pub inline fn getWindowMouseGrab(window: *Window) bool {
|
||||||
return c.SDL_GetWindowMouseGrab(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 c.SDL_SetWindowMouseRect(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(window));
|
return @ptrCast(c.SDL_GetWindowMouseRect(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowOpacity(window: *Window, opacity: f32) bool {
|
pub inline fn setWindowOpacity(window: *Window, opacity: f32) bool {
|
||||||
return c.SDL_SetWindowOpacity(window, opacity);
|
return @bitCast(c.SDL_SetWindowOpacity(@ptrCast(window), opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowOpacity(window: *Window) f32 {
|
pub inline fn getWindowOpacity(window: *Window) f32 {
|
||||||
return c.SDL_GetWindowOpacity(window);
|
return c.SDL_GetWindowOpacity(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowParent(window: *Window, parent: ?*Window) bool {
|
pub inline fn setWindowParent(window: *Window, parent: ?*Window) bool {
|
||||||
return c.SDL_SetWindowParent(window, parent);
|
return @bitCast(c.SDL_SetWindowParent(@ptrCast(window), @ptrCast(parent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowModal(window: *Window, modal: bool) bool {
|
pub inline fn setWindowModal(window: *Window, modal: bool) bool {
|
||||||
return c.SDL_SetWindowModal(window, modal);
|
return @bitCast(c.SDL_SetWindowModal(@ptrCast(window), @bitCast(modal)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowFocusable(window: *Window, focusable: bool) bool {
|
pub inline fn setWindowFocusable(window: *Window, focusable: bool) bool {
|
||||||
return c.SDL_SetWindowFocusable(window, focusable);
|
return @bitCast(c.SDL_SetWindowFocusable(@ptrCast(window), @bitCast(focusable)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn showWindowSystemMenu(window: *Window, x: c_int, y: c_int) bool {
|
pub inline fn showWindowSystemMenu(window: *Window, x: c_int, y: c_int) bool {
|
||||||
return c.SDL_ShowWindowSystemMenu(window, x, y);
|
return @bitCast(c.SDL_ShowWindowSystemMenu(@ptrCast(window), x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowHitTest(window: *Window, callback: HitTest, callback_data: ?*anyopaque) bool {
|
pub inline fn setWindowHitTest(window: *Window, callback: HitTest, callback_data: ?*anyopaque) bool {
|
||||||
return c.SDL_SetWindowHitTest(window, callback, callback_data);
|
return @bitCast(c.SDL_SetWindowHitTest(@ptrCast(window), callback, callback_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setWindowShape(window: *Window, shape: ?*Surface) bool {
|
pub inline fn setWindowShape(window: *Window, shape: ?*Surface) bool {
|
||||||
return c.SDL_SetWindowShape(window, shape);
|
return @bitCast(c.SDL_SetWindowShape(@ptrCast(window), @ptrCast(shape)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn flashWindow(window: *Window, operation: FlashOperation) bool {
|
pub inline fn flashWindow(window: *Window, operation: FlashOperation) bool {
|
||||||
return c.SDL_FlashWindow(window, @intFromEnum(operation));
|
return @bitCast(c.SDL_FlashWindow(@ptrCast(window), @intFromEnum(operation)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn setWindowProgressState(window: *Window, state: ProgressState) bool {
|
||||||
|
return @bitCast(c.SDL_SetWindowProgressState(@ptrCast(window), state));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getWindowProgressState(window: *Window) ProgressState {
|
||||||
|
return c.SDL_GetWindowProgressState(@ptrCast(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn setWindowProgressValue(window: *Window, value: f32) bool {
|
||||||
|
return @bitCast(c.SDL_SetWindowProgressValue(@ptrCast(window), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getWindowProgressValue(window: *Window) f32 {
|
||||||
|
return c.SDL_GetWindowProgressValue(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn destroyWindow(window: *Window) void {
|
pub inline fn destroyWindow(window: *Window) void {
|
||||||
return c.SDL_DestroyWindow(window);
|
return c.SDL_DestroyWindow(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_CreateContext(window: *Window) GLContext {
|
pub inline fn gl_CreateContext(window: *Window) GLContext {
|
||||||
return c.SDL_GL_CreateContext(window);
|
return c.SDL_GL_CreateContext(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_MakeCurrent(window: *Window, context: GLContext) bool {
|
pub inline fn gl_MakeCurrent(window: *Window, context: GLContext) bool {
|
||||||
return c.SDL_GL_MakeCurrent(window, context);
|
return @bitCast(c.SDL_GL_MakeCurrent(@ptrCast(window), context));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn egl_GetWindowSurface(window: *Window) EGLSurface {
|
pub inline fn egl_GetWindowSurface(window: *Window) EGLSurface {
|
||||||
return c.SDL_EGL_GetWindowSurface(window);
|
return c.SDL_EGL_GetWindowSurface(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_SwapWindow(window: *Window) bool {
|
pub inline fn gl_SwapWindow(window: *Window) bool {
|
||||||
return c.SDL_GL_SwapWindow(window);
|
return @bitCast(c.SDL_GL_SwapWindow(@ptrCast(window)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -352,12 +372,15 @@ pub const WindowFlags = packed struct(u64) {
|
||||||
windowTooltip: bool = false, // window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window
|
windowTooltip: bool = false, // window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window
|
||||||
windowPopupMenu: bool = false, // window should be treated as a popup menu, requires a parent window
|
windowPopupMenu: bool = false, // window should be treated as a popup menu, requires a parent window
|
||||||
windowKeyboardGrabbed: bool = false, // window has grabbed keyboard input
|
windowKeyboardGrabbed: bool = false, // window has grabbed keyboard input
|
||||||
|
windowFillDocument: bool = false, // window is in fill-document mode (Emscripten only), since SDL 3.4.0
|
||||||
windowVulkan: bool = false, // window usable for Vulkan surface
|
windowVulkan: bool = false, // window usable for Vulkan surface
|
||||||
windowMetal: bool = false, // window usable for Metal view
|
windowMetal: bool = false, // window usable for Metal view
|
||||||
windowTransparent: bool = false, // window with transparent buffer
|
windowTransparent: bool = false, // window with transparent buffer
|
||||||
windowNotFocusable: bool = false, // window should not be focusable
|
windowNotFocusable: bool = false, // window should not be focusable
|
||||||
pad0: u38 = 0,
|
pad0: u37 = 0,
|
||||||
rsvd: bool = false,
|
rsvd: bool = false,
|
||||||
|
|
||||||
|
pub const None = WindowFlags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const FlashOperation = enum(c_int) {
|
pub const FlashOperation = enum(c_int) {
|
||||||
|
|
@ -366,6 +389,15 @@ pub const FlashOperation = enum(c_int) {
|
||||||
flashUntilFocused, //Flash the window until it gets focus
|
flashUntilFocused, //Flash the window until it gets focus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const ProgressState = enum(c_int) {
|
||||||
|
progressStateInvalid = -1, //An invalid progress state indicating an error; check SDL_GetError()
|
||||||
|
progressStateNone, //No progress bar is shown
|
||||||
|
progressStateIndeterminate, //The progress bar is shown in a indeterminate state
|
||||||
|
progressStateNormal, //The progress bar is shown in a normal state
|
||||||
|
progressStatePaused, //The progress bar is shown in a paused state
|
||||||
|
progressStateError, //The progress bar is shown in a state indicating the application had an error
|
||||||
|
};
|
||||||
|
|
||||||
pub const GLContext = *anyopaque;
|
pub const GLContext = *anyopaque;
|
||||||
|
|
||||||
pub const EGLDisplay = ?*anyopaque;
|
pub const EGLDisplay = ?*anyopaque;
|
||||||
|
|
@ -405,7 +437,7 @@ pub const GLAttr = enum(c_int) {
|
||||||
glContextFlags, //some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0.
|
glContextFlags, //some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0.
|
||||||
glContextProfileMask, //type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform.
|
glContextProfileMask, //type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform.
|
||||||
glShareWithCurrentContext, //OpenGL context sharing; defaults to 0.
|
glShareWithCurrentContext, //OpenGL context sharing; defaults to 0.
|
||||||
glFramebufferSrgbCapable, //requests sRGB capable visual; defaults to 0.
|
glFramebufferSrgbCapable, //requests sRGB-capable visual if 1. Defaults to -1 ("don't care"). This is a request; GL drivers might not comply!
|
||||||
glContextReleaseBehavior, //sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH.
|
glContextReleaseBehavior, //sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH.
|
||||||
glContextResetNotification, //set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION.
|
glContextResetNotification, //set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION.
|
||||||
glContextNoError,
|
glContextNoError,
|
||||||
|
|
@ -438,7 +470,7 @@ pub inline fn getSystemTheme() SystemTheme {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplays(count: *c_int) ?*DisplayID {
|
pub inline fn getDisplays(count: *c_int) ?*DisplayID {
|
||||||
return c.SDL_GetDisplays(@ptrCast(count));
|
return @ptrCast(c.SDL_GetDisplays(@ptrCast(count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getPrimaryDisplay() DisplayID {
|
pub inline fn getPrimaryDisplay() DisplayID {
|
||||||
|
|
@ -454,11 +486,11 @@ pub inline fn getDisplayName(displayID: DisplayID) [*c]const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayBounds(displayID: DisplayID, rect: ?*Rect) bool {
|
pub inline fn getDisplayBounds(displayID: DisplayID, rect: ?*Rect) bool {
|
||||||
return c.SDL_GetDisplayBounds(displayID, rect);
|
return @bitCast(c.SDL_GetDisplayBounds(displayID, @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getDisplayUsableBounds(displayID: DisplayID, rect: ?*Rect) bool {
|
pub inline fn getDisplayUsableBounds(displayID: DisplayID, rect: ?*Rect) bool {
|
||||||
return c.SDL_GetDisplayUsableBounds(displayID, rect);
|
return @bitCast(c.SDL_GetDisplayUsableBounds(displayID, @ptrCast(rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getNaturalDisplayOrientation(displayID: DisplayID) DisplayOrientation {
|
pub inline fn getNaturalDisplayOrientation(displayID: DisplayID) DisplayOrientation {
|
||||||
|
|
@ -478,7 +510,7 @@ pub inline fn getFullscreenDisplayModes(displayID: DisplayID, count: *c_int) [*c
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
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 {
|
||||||
|
|
@ -502,19 +534,19 @@ pub inline fn getWindows(count: *c_int) [*c][*c]Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
return @ptrCast(c.SDL_CreateWindow(title, w, h, @bitCast(flags)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createWindowWithProperties(props: PropertiesID) ?*Window {
|
pub inline fn createWindowWithProperties(props: PropertiesID) ?*Window {
|
||||||
return c.SDL_CreateWindowWithProperties(props);
|
return @ptrCast(c.SDL_CreateWindowWithProperties(props));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getWindowFromID(id: WindowID) ?*Window {
|
pub inline fn getWindowFromID(id: WindowID) ?*Window {
|
||||||
return c.SDL_GetWindowFromID(id);
|
return @ptrCast(c.SDL_GetWindowFromID(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getGrabbedWindow() ?*Window {
|
pub inline fn getGrabbedWindow() ?*Window {
|
||||||
return c.SDL_GetGrabbedWindow();
|
return @ptrCast(c.SDL_GetGrabbedWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const HitTestResult = enum(c_int) {
|
pub const HitTestResult = enum(c_int) {
|
||||||
|
|
@ -533,19 +565,19 @@ pub const HitTestResult = enum(c_int) {
|
||||||
pub const HitTest = c.SDL_HitTest;
|
pub const HitTest = c.SDL_HitTest;
|
||||||
|
|
||||||
pub inline fn screenSaverEnabled() bool {
|
pub inline fn screenSaverEnabled() bool {
|
||||||
return c.SDL_ScreenSaverEnabled();
|
return @bitCast(c.SDL_ScreenSaverEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn enableScreenSaver() bool {
|
pub inline fn enableScreenSaver() bool {
|
||||||
return c.SDL_EnableScreenSaver();
|
return @bitCast(c.SDL_EnableScreenSaver());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn disableScreenSaver() bool {
|
pub inline fn disableScreenSaver() bool {
|
||||||
return c.SDL_DisableScreenSaver();
|
return @bitCast(c.SDL_DisableScreenSaver());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_LoadLibrary(path: [*c]const u8) bool {
|
pub inline fn gl_LoadLibrary(path: [*c]const u8) bool {
|
||||||
return c.SDL_GL_LoadLibrary(path);
|
return @bitCast(c.SDL_GL_LoadLibrary(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetProcAddress(proc: [*c]const u8) FunctionPointer {
|
pub inline fn gl_GetProcAddress(proc: [*c]const u8) FunctionPointer {
|
||||||
|
|
@ -561,7 +593,7 @@ pub inline fn gl_UnloadLibrary() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_ExtensionSupported(extension: [*c]const u8) bool {
|
pub inline fn gl_ExtensionSupported(extension: [*c]const u8) bool {
|
||||||
return c.SDL_GL_ExtensionSupported(extension);
|
return @bitCast(c.SDL_GL_ExtensionSupported(extension));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_ResetAttributes() void {
|
pub inline fn gl_ResetAttributes() void {
|
||||||
|
|
@ -569,15 +601,15 @@ pub inline fn gl_ResetAttributes() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_SetAttribute(attr: GLAttr, value: c_int) bool {
|
pub inline fn gl_SetAttribute(attr: GLAttr, value: c_int) bool {
|
||||||
return c.SDL_GL_SetAttribute(attr, value);
|
return @bitCast(c.SDL_GL_SetAttribute(attr, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetAttribute(attr: GLAttr, value: *c_int) bool {
|
pub inline fn gl_GetAttribute(attr: GLAttr, value: *c_int) bool {
|
||||||
return c.SDL_GL_GetAttribute(attr, @ptrCast(value));
|
return @bitCast(c.SDL_GL_GetAttribute(attr, @ptrCast(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetCurrentWindow() ?*Window {
|
pub inline fn gl_GetCurrentWindow() ?*Window {
|
||||||
return c.SDL_GL_GetCurrentWindow();
|
return @ptrCast(c.SDL_GL_GetCurrentWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetCurrentContext() GLContext {
|
pub inline fn gl_GetCurrentContext() GLContext {
|
||||||
|
|
@ -597,13 +629,13 @@ pub inline fn egl_SetAttributeCallbacks(platformAttribCallback: EGLAttribArrayCa
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_SetSwapInterval(interval: c_int) bool {
|
pub inline fn gl_SetSwapInterval(interval: c_int) bool {
|
||||||
return c.SDL_GL_SetSwapInterval(interval);
|
return @bitCast(c.SDL_GL_SetSwapInterval(interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_GetSwapInterval(interval: *c_int) bool {
|
pub inline fn gl_GetSwapInterval(interval: *c_int) bool {
|
||||||
return c.SDL_GL_GetSwapInterval(@ptrCast(interval));
|
return @bitCast(c.SDL_GL_GetSwapInterval(@ptrCast(interval)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn gl_DestroyContext(context: GLContext) bool {
|
pub inline fn gl_DestroyContext(context: GLContext) bool {
|
||||||
return c.SDL_GL_DestroyContext(context);
|
return @bitCast(c.SDL_GL_DestroyContext(context));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@
|
||||||
],
|
],
|
||||||
"function_pointers": [],
|
"function_pointers": [],
|
||||||
"c_type_aliases": [
|
"c_type_aliases": [
|
||||||
|
{
|
||||||
|
"name": "SDL_AudioStreamDataCompleteCallback"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_AudioStreamCallback"
|
"name": "SDL_AudioStreamCallback"
|
||||||
},
|
},
|
||||||
|
|
@ -533,6 +536,54 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PutAudioStreamDataNoCopy",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "stream",
|
||||||
|
"type": "SDL_AudioStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "buf",
|
||||||
|
"type": "const void *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "len",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "callback",
|
||||||
|
"type": "SDL_AudioStreamDataCompleteCallback"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userdata",
|
||||||
|
"type": "void *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PutAudioStreamPlanarData",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "stream",
|
||||||
|
"type": "SDL_AudioStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "channel_buffers",
|
||||||
|
"type": "const void * const *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "num_channels",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "num_samples",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GetAudioStreamData",
|
"name": "SDL_GetAudioStreamData",
|
||||||
"return_type": "int",
|
"return_type": "int",
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,17 @@
|
||||||
"name": "SDL_CAMERA_POSITION_BACK_FACING"
|
"name": "SDL_CAMERA_POSITION_BACK_FACING"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_CameraPermissionState",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_CAMERA_PERMISSION_STATE_PENDING"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_CAMERA_PERMISSION_STATE_APPROVED"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"structs": [
|
"structs": [
|
||||||
|
|
@ -149,7 +160,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GetCameraPermissionState",
|
"name": "SDL_GetCameraPermissionState",
|
||||||
"return_type": "int",
|
"return_type": "SDL_CameraPermissionState",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "camera",
|
"name": "camera",
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,10 @@
|
||||||
"name": "SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED",
|
"name": "SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED",
|
||||||
"comment": "Display has changed content scale"
|
"comment": "Display has changed content scale"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED",
|
||||||
|
"comment": "Display has changed usable bounds"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WINDOW_SHOWN",
|
"name": "SDL_EVENT_WINDOW_SHOWN",
|
||||||
"value": "0x202",
|
"value": "0x202",
|
||||||
|
|
@ -87,8 +91,7 @@
|
||||||
"comment": "Window has been hidden"
|
"comment": "Window has been hidden"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WINDOW_EXPOSED",
|
"name": "SDL_EVENT_WINDOW_EXPOSED"
|
||||||
"comment": "Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_WINDOW_MOVED",
|
"name": "SDL_EVENT_WINDOW_MOVED",
|
||||||
|
|
@ -209,6 +212,14 @@
|
||||||
"name": "SDL_EVENT_TEXT_EDITING_CANDIDATES",
|
"name": "SDL_EVENT_TEXT_EDITING_CANDIDATES",
|
||||||
"comment": "Keyboard text editing candidates"
|
"comment": "Keyboard text editing candidates"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_SCREEN_KEYBOARD_SHOWN",
|
||||||
|
"comment": "The on-screen keyboard has been shown"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_SCREEN_KEYBOARD_HIDDEN",
|
||||||
|
"comment": "The on-screen keyboard has been hidden"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_MOUSE_MOTION",
|
"name": "SDL_EVENT_MOUSE_MOTION",
|
||||||
"value": "0x400",
|
"value": "0x400",
|
||||||
|
|
@ -329,10 +340,23 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_FINGER_CANCELED"
|
"name": "SDL_EVENT_FINGER_CANCELED"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_PINCH_BEGIN",
|
||||||
|
"value": "0x710",
|
||||||
|
"comment": "Pinch gesture started"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_PINCH_UPDATE",
|
||||||
|
"comment": "Pinch gesture updated"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_EVENT_PINCH_END",
|
||||||
|
"comment": "Pinch gesture ended"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_CLIPBOARD_UPDATE",
|
"name": "SDL_EVENT_CLIPBOARD_UPDATE",
|
||||||
"value": "0x900",
|
"value": "0x900",
|
||||||
"comment": "The clipboard or primary selection changed"
|
"comment": "The clipboard changed"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_EVENT_DROP_FILE",
|
"name": "SDL_EVENT_DROP_FILE",
|
||||||
|
|
@ -496,7 +520,7 @@
|
||||||
{
|
{
|
||||||
"name": "_type",
|
"name": "_type",
|
||||||
"type": "SDL_EventType",
|
"type": "SDL_EventType",
|
||||||
"comment": "SDL_DISPLAYEVENT_*"
|
"comment": "SDL_EVENT_DISPLAY_*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "reserved",
|
"name": "reserved",
|
||||||
|
|
@ -1554,6 +1578,35 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PinchFingerEvent",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "_type",
|
||||||
|
"type": "SDL_EventType",
|
||||||
|
"comment": "::SDL_EVENT_PINCH_BEGIN or ::SDL_EVENT_PINCH_UPDATE or ::SDL_EVENT_PINCH_END"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "reserved",
|
||||||
|
"type": "Uint32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "timestamp",
|
||||||
|
"type": "Uint64",
|
||||||
|
"comment": "In nanoseconds, populated using SDL_GetTicksNS()"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scale",
|
||||||
|
"type": "float",
|
||||||
|
"comment": "The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is \"zoom out\". Scale > 1 is \"zoom in\"."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windowID",
|
||||||
|
"type": "SDL_WindowID",
|
||||||
|
"comment": "The window underneath the finger, if any"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_PenProximityEvent",
|
"name": "SDL_PenProximityEvent",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|
@ -1926,7 +1979,7 @@
|
||||||
{
|
{
|
||||||
"name": "_type",
|
"name": "_type",
|
||||||
"type": "Uint32",
|
"type": "Uint32",
|
||||||
"comment": "SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration"
|
"comment": "SDL_EVENT_USER through SDL_EVENT_LAST, Uint32 because these are not in the SDL_EventType enumeration"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "reserved",
|
"name": "reserved",
|
||||||
|
|
@ -2114,6 +2167,11 @@
|
||||||
"type": "SDL_TouchFingerEvent",
|
"type": "SDL_TouchFingerEvent",
|
||||||
"comment": "Touch finger event data"
|
"comment": "Touch finger event data"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "pinch",
|
||||||
|
"type": "SDL_PinchFingerEvent",
|
||||||
|
"comment": "Pinch event data"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "pproximity",
|
"name": "pproximity",
|
||||||
"type": "SDL_PenProximityEvent",
|
"type": "SDL_PenProximityEvent",
|
||||||
|
|
@ -2399,6 +2457,24 @@
|
||||||
"type": "const SDL_Event *"
|
"type": "const SDL_Event *"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetEventDescription",
|
||||||
|
"return_type": "int",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "event",
|
||||||
|
"type": "const SDL_Event *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "buf",
|
||||||
|
"type": "char *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "buflen",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -42,6 +42,9 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR"
|
"name": "SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GAMEPAD_TYPE_GAMECUBE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_TYPE_COUNT"
|
"name": "SDL_GAMEPAD_TYPE_COUNT"
|
||||||
}
|
}
|
||||||
|
|
@ -105,19 +108,19 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1",
|
"name": "SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1",
|
||||||
"comment": "Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1)"
|
"comment": "Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_LEFT_PADDLE1",
|
"name": "SDL_GAMEPAD_BUTTON_LEFT_PADDLE1",
|
||||||
"comment": "Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3)"
|
"comment": "Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2",
|
"name": "SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2",
|
||||||
"comment": "Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2)"
|
"comment": "Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_LEFT_PADDLE2",
|
"name": "SDL_GAMEPAD_BUTTON_LEFT_PADDLE2",
|
||||||
"comment": "Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4)"
|
"comment": "Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_TOUCHPAD",
|
"name": "SDL_GAMEPAD_BUTTON_TOUCHPAD",
|
||||||
|
|
@ -129,11 +132,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_MISC3",
|
"name": "SDL_GAMEPAD_BUTTON_MISC3",
|
||||||
"comment": "Additional button"
|
"comment": "Additional button (e.g. Nintendo GameCube left trigger click)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_MISC4",
|
"name": "SDL_GAMEPAD_BUTTON_MISC4",
|
||||||
"comment": "Additional button"
|
"comment": "Additional button (e.g. Nintendo GameCube right trigger click)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GAMEPAD_BUTTON_MISC5",
|
"name": "SDL_GAMEPAD_BUTTON_MISC5",
|
||||||
|
|
|
||||||
|
|
@ -1701,8 +1701,9 @@
|
||||||
"comment": "Reserved for future use. Must be set to false."
|
"comment": "Reserved for future use. Must be set to false."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "padding1",
|
"name": "enable_alpha_to_coverage",
|
||||||
"type": "Uint8"
|
"type": "bool",
|
||||||
|
"comment": "true enables the alpha-to-coverage feature."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "padding2",
|
"name": "padding2",
|
||||||
|
|
@ -2060,12 +2061,14 @@
|
||||||
"comment": "The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used."
|
"comment": "The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "padding1",
|
"name": "mip_level",
|
||||||
"type": "Uint8"
|
"type": "Uint8",
|
||||||
|
"comment": "The mip level to use as the depth stencil target."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "padding2",
|
"name": "layer",
|
||||||
"type": "Uint8"
|
"type": "Uint8",
|
||||||
|
"comment": "The layer index to use as the depth stencil target."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -2214,6 +2217,46 @@
|
||||||
"type": "Uint8"
|
"type": "Uint8"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GPUVulkanOptions",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "vulkan_api_version",
|
||||||
|
"type": "Uint32",
|
||||||
|
"comment": "The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "feature_list",
|
||||||
|
"type": "void *",
|
||||||
|
"comment": "Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vulkan_10_physical_device_features",
|
||||||
|
"type": "void *",
|
||||||
|
"comment": "Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "device_extension_count",
|
||||||
|
"type": "Uint32",
|
||||||
|
"comment": "Number of additional device extensions to require."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "device_extension_names",
|
||||||
|
"type": "const char **",
|
||||||
|
"comment": "Pointer to a list of additional device extensions to require."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "instance_extension_count",
|
||||||
|
"type": "Uint32",
|
||||||
|
"comment": "Number of additional instance extensions to require."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "instance_extension_names",
|
||||||
|
"type": "const char **",
|
||||||
|
"comment": "Pointer to a list of additional instance extensions to require."
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"unions": [],
|
"unions": [],
|
||||||
|
|
@ -2420,6 +2463,16 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetGPUDeviceProperties",
|
||||||
|
"return_type": "SDL_PropertiesID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "device",
|
||||||
|
"type": "SDL_GPUDevice *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_CreateGPUComputePipeline",
|
"name": "SDL_CreateGPUComputePipeline",
|
||||||
"return_type": "SDL_GPUComputePipeline *",
|
"return_type": "SDL_GPUComputePipeline *",
|
||||||
|
|
@ -3858,6 +3911,26 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetPixelFormatFromGPUTextureFormat",
|
||||||
|
"return_type": "SDL_PixelFormat",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "format",
|
||||||
|
"type": "SDL_GPUTextureFormat"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetGPUTextureFormatFromPixelFormat",
|
||||||
|
"return_type": "SDL_GPUTextureFormat",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "format",
|
||||||
|
"type": "SDL_PixelFormat"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GDKSuspendGPU",
|
"name": "SDL_GDKSuspendGPU",
|
||||||
"return_type": "void",
|
"return_type": "void",
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,18 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"typedefs": [
|
"typedefs": [
|
||||||
|
{
|
||||||
|
"name": "SDL_HapticEffectType",
|
||||||
|
"underlying_type": "Uint16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_HapticDirectionType",
|
||||||
|
"underlying_type": "Uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_HapticEffectID",
|
||||||
|
"underlying_type": "int"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_HapticID",
|
"name": "SDL_HapticID",
|
||||||
"underlying_type": "Uint32"
|
"underlying_type": "Uint32"
|
||||||
|
|
@ -20,7 +32,7 @@
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"name": "_type",
|
"name": "_type",
|
||||||
"type": "Uint8",
|
"type": "SDL_HapticDirectionType",
|
||||||
"comment": "The type of encoding."
|
"comment": "The type of encoding."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +47,7 @@
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"name": "_type",
|
"name": "_type",
|
||||||
"type": "Uint16",
|
"type": "SDL_HapticEffectType",
|
||||||
"comment": "SDL_HAPTIC_CONSTANT"
|
"comment": "SDL_HAPTIC_CONSTANT"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -225,7 +237,7 @@
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"name": "_type",
|
"name": "_type",
|
||||||
"type": "Uint16",
|
"type": "SDL_HapticEffectType",
|
||||||
"comment": "SDL_HAPTIC_RAMP"
|
"comment": "SDL_HAPTIC_RAMP"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -290,7 +302,7 @@
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"name": "_type",
|
"name": "_type",
|
||||||
"type": "Uint16",
|
"type": "SDL_HapticEffectType",
|
||||||
"comment": "SDL_HAPTIC_LEFTRIGHT"
|
"comment": "SDL_HAPTIC_LEFTRIGHT"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -315,7 +327,7 @@
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"name": "_type",
|
"name": "_type",
|
||||||
"type": "Uint16",
|
"type": "SDL_HapticEffectType",
|
||||||
"comment": "SDL_HAPTIC_CUSTOM"
|
"comment": "SDL_HAPTIC_CUSTOM"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -392,7 +404,7 @@
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"name": "_type",
|
"name": "_type",
|
||||||
"type": "Uint16",
|
"type": "SDL_HapticEffectType",
|
||||||
"comment": "Effect type."
|
"comment": "Effect type."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -586,7 +598,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_CreateHapticEffect",
|
"name": "SDL_CreateHapticEffect",
|
||||||
"return_type": "int",
|
"return_type": "SDL_HapticEffectID",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "haptic",
|
"name": "haptic",
|
||||||
|
|
@ -608,7 +620,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "effect",
|
"name": "effect",
|
||||||
"type": "int"
|
"type": "SDL_HapticEffectID"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "data",
|
"name": "data",
|
||||||
|
|
@ -626,7 +638,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "effect",
|
"name": "effect",
|
||||||
"type": "int"
|
"type": "SDL_HapticEffectID"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "iterations",
|
"name": "iterations",
|
||||||
|
|
@ -644,7 +656,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "effect",
|
"name": "effect",
|
||||||
"type": "int"
|
"type": "SDL_HapticEffectID"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -658,7 +670,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "effect",
|
"name": "effect",
|
||||||
"type": "int"
|
"type": "SDL_HapticEffectID"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -672,7 +684,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "effect",
|
"name": "effect",
|
||||||
"type": "int"
|
"type": "SDL_HapticEffectID"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"function_pointers": [],
|
"function_pointers": [],
|
||||||
"c_type_aliases": [],
|
"c_type_aliases": [
|
||||||
|
{
|
||||||
|
"name": "SDL_MouseMotionTransformCallback"
|
||||||
|
}
|
||||||
|
],
|
||||||
"enums": [
|
"enums": [
|
||||||
{
|
{
|
||||||
"name": "SDL_SystemCursor",
|
"name": "SDL_SystemCursor",
|
||||||
|
|
@ -116,7 +120,23 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"structs": [],
|
"structs": [
|
||||||
|
{
|
||||||
|
"name": "SDL_CursorFrameInfo",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "surface",
|
||||||
|
"type": "SDL_Surface *",
|
||||||
|
"comment": "The surface data for this frame"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "duration",
|
||||||
|
"type": "Uint32",
|
||||||
|
"comment": "The frame duration in milliseconds (a duration of 0 is infinite)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"unions": [],
|
"unions": [],
|
||||||
"flags": [
|
"flags": [
|
||||||
{
|
{
|
||||||
|
|
@ -251,6 +271,20 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetRelativeMouseTransform",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "callback",
|
||||||
|
"type": "SDL_MouseMotionTransformCallback"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userdata",
|
||||||
|
"type": "void *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SetWindowRelativeMouseMode",
|
"name": "SDL_SetWindowRelativeMouseMode",
|
||||||
"return_type": "bool",
|
"return_type": "bool",
|
||||||
|
|
@ -333,6 +367,28 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_CreateAnimatedCursor",
|
||||||
|
"return_type": "SDL_Cursor *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "frames",
|
||||||
|
"type": "SDL_CursorFrameInfo *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "frame_count",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hot_x",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hot_y",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_CreateSystemCursor",
|
"name": "SDL_CreateSystemCursor",
|
||||||
"return_type": "SDL_Cursor *",
|
"return_type": "SDL_Cursor *",
|
||||||
|
|
|
||||||
|
|
@ -532,7 +532,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_COLORSPACE_YUV_DEFAULT",
|
"name": "SDL_COLORSPACE_YUV_DEFAULT",
|
||||||
"value": "SDL_COLORSPACE_JPEG",
|
"value": "SDL_COLORSPACE_BT601_LIMITED",
|
||||||
"comment": "The default colorspace for YUV surfaces if no colorspace is specified"
|
"comment": "The default colorspace for YUV surfaces if no colorspace is specified"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -858,7 +858,7 @@
|
||||||
"return_type": "void",
|
"return_type": "void",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "pixel",
|
"name": "pixelvalue",
|
||||||
"type": "Uint32"
|
"type": "Uint32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -888,7 +888,7 @@
|
||||||
"return_type": "void",
|
"return_type": "void",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "pixel",
|
"name": "pixelvalue",
|
||||||
"type": "Uint32"
|
"type": "Uint32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
285
json/render.json
285
json/render.json
|
|
@ -6,6 +6,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_Texture"
|
"name": "SDL_Texture"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GPURenderState"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"typedefs": [],
|
"typedefs": [],
|
||||||
|
|
@ -29,6 +32,23 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TextureAddressMode",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_TEXTURE_ADDRESS_AUTO",
|
||||||
|
"comment": "Wrapping is enabled if texture coordinates are outside [0, 1], this is the default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TEXTURE_ADDRESS_CLAMP",
|
||||||
|
"comment": "Texture coordinates are clamped to the [0, 1] range"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_TEXTURE_ADDRESS_WRAP",
|
||||||
|
"comment": "The texture is repeated (tiled)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_RendererLogicalPresentation",
|
"name": "SDL_RendererLogicalPresentation",
|
||||||
"values": [
|
"values": [
|
||||||
|
|
@ -42,7 +62,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_LOGICAL_PRESENTATION_LETTERBOX",
|
"name": "SDL_LOGICAL_PRESENTATION_LETTERBOX",
|
||||||
"comment": "The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars"
|
"comment": "The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_LOGICAL_PRESENTATION_OVERSCAN",
|
"name": "SDL_LOGICAL_PRESENTATION_OVERSCAN",
|
||||||
|
|
@ -75,6 +95,51 @@
|
||||||
"comment": "Normalized texture coordinates, if needed"
|
"comment": "Normalized texture coordinates, if needed"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GPURenderStateCreateInfo",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "fragment_shader",
|
||||||
|
"type": "SDL_GPUShader *",
|
||||||
|
"comment": "The fragment shader to use when this render state is active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "num_sampler_bindings",
|
||||||
|
"type": "Sint32",
|
||||||
|
"comment": "The number of additional fragment samplers to bind when this render state is active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sampler_bindings",
|
||||||
|
"type": "const SDL_GPUTextureSamplerBinding *",
|
||||||
|
"comment": "Additional fragment samplers to bind when this render state is active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "num_storage_textures",
|
||||||
|
"type": "Sint32",
|
||||||
|
"comment": "The number of storage textures to bind when this render state is active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "storage_textures",
|
||||||
|
"type": "SDL_GPUTexture *const *",
|
||||||
|
"comment": "Storage textures to bind when this render state is active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "num_storage_buffers",
|
||||||
|
"type": "Sint32",
|
||||||
|
"comment": "The number of storage buffers to bind when this render state is active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "storage_buffers",
|
||||||
|
"type": "SDL_GPUBuffer *const *",
|
||||||
|
"comment": "Storage buffers to bind when this render state is active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "props",
|
||||||
|
"type": "SDL_PropertiesID",
|
||||||
|
"comment": "A properties ID for extensions. Should be 0 if no extensions are needed."
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"unions": [],
|
"unions": [],
|
||||||
|
|
@ -149,6 +214,30 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_CreateGPURenderer",
|
||||||
|
"return_type": "SDL_Renderer *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "device",
|
||||||
|
"type": "SDL_GPUDevice *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "window",
|
||||||
|
"type": "SDL_Window *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetGPURendererDevice",
|
||||||
|
"return_type": "SDL_GPUDevice *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "renderer",
|
||||||
|
"type": "SDL_Renderer *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_CreateSoftwareRenderer",
|
"name": "SDL_CreateSoftwareRenderer",
|
||||||
"return_type": "SDL_Renderer *",
|
"return_type": "SDL_Renderer *",
|
||||||
|
|
@ -327,6 +416,30 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetTexturePalette",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "texture",
|
||||||
|
"type": "SDL_Texture *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "palette",
|
||||||
|
"type": "SDL_Palette *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetTexturePalette",
|
||||||
|
"return_type": "SDL_Palette *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "texture",
|
||||||
|
"type": "SDL_Texture *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SetTextureColorMod",
|
"name": "SDL_SetTextureColorMod",
|
||||||
"return_type": "bool",
|
"return_type": "bool",
|
||||||
|
|
@ -1409,6 +1522,52 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_RenderTexture9GridTiled",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "renderer",
|
||||||
|
"type": "SDL_Renderer *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "texture",
|
||||||
|
"type": "SDL_Texture *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "srcrect",
|
||||||
|
"type": "const SDL_FRect *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "left_width",
|
||||||
|
"type": "float"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "right_width",
|
||||||
|
"type": "float"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "top_height",
|
||||||
|
"type": "float"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bottom_height",
|
||||||
|
"type": "float"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scale",
|
||||||
|
"type": "float"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dstrect",
|
||||||
|
"type": "const SDL_FRect *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tileScale",
|
||||||
|
"type": "float"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_RenderGeometry",
|
"name": "SDL_RenderGeometry",
|
||||||
"return_type": "bool",
|
"return_type": "bool",
|
||||||
|
|
@ -1493,6 +1652,42 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetRenderTextureAddressMode",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "renderer",
|
||||||
|
"type": "SDL_Renderer *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "u_mode",
|
||||||
|
"type": "SDL_TextureAddressMode"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v_mode",
|
||||||
|
"type": "SDL_TextureAddressMode"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetRenderTextureAddressMode",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "renderer",
|
||||||
|
"type": "SDL_Renderer *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "u_mode",
|
||||||
|
"type": "SDL_TextureAddressMode *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v_mode",
|
||||||
|
"type": "SDL_TextureAddressMode *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_RenderReadPixels",
|
"name": "SDL_RenderReadPixels",
|
||||||
"return_type": "SDL_Surface *",
|
"return_type": "SDL_Surface *",
|
||||||
|
|
@ -1638,6 +1833,94 @@
|
||||||
"type": "const char *"
|
"type": "const char *"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetDefaultTextureScaleMode",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "renderer",
|
||||||
|
"type": "SDL_Renderer *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scale_mode",
|
||||||
|
"type": "SDL_ScaleMode"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetDefaultTextureScaleMode",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "renderer",
|
||||||
|
"type": "SDL_Renderer *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scale_mode",
|
||||||
|
"type": "SDL_ScaleMode *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_CreateGPURenderState",
|
||||||
|
"return_type": "SDL_GPURenderState *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "renderer",
|
||||||
|
"type": "SDL_Renderer *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "createinfo",
|
||||||
|
"type": "SDL_GPURenderStateCreateInfo *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetGPURenderStateFragmentUniforms",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "state",
|
||||||
|
"type": "SDL_GPURenderState *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "slot_index",
|
||||||
|
"type": "Uint32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "data",
|
||||||
|
"type": "const void *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "length",
|
||||||
|
"type": "Uint32"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetGPURenderState",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "renderer",
|
||||||
|
"type": "SDL_Renderer *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "state",
|
||||||
|
"type": "SDL_GPURenderState *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_DestroyGPURenderState",
|
||||||
|
"return_type": "void",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "state",
|
||||||
|
"type": "SDL_GPURenderState *"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -19,6 +19,9 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_SCALEMODE_LINEAR",
|
"name": "SDL_SCALEMODE_LINEAR",
|
||||||
"comment": "linear filtering"
|
"comment": "linear filtering"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SCALEMODE_PIXELART"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -36,6 +39,11 @@
|
||||||
{
|
{
|
||||||
"name": "SDL_FLIP_VERTICAL",
|
"name": "SDL_FLIP_VERTICAL",
|
||||||
"comment": "flip vertically"
|
"comment": "flip vertically"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_FLIP_HORIZONTAL_AND_VERTICAL",
|
||||||
|
"value": "(SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL)",
|
||||||
|
"comment": "flip horizontally and vertically (not a diagonal flip)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -261,6 +269,30 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_LoadSurface_IO",
|
||||||
|
"return_type": "SDL_Surface *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "closeio",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_LoadSurface",
|
||||||
|
"return_type": "SDL_Surface *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "file",
|
||||||
|
"type": "const char *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_LoadBMP_IO",
|
"name": "SDL_LoadBMP_IO",
|
||||||
"return_type": "SDL_Surface *",
|
"return_type": "SDL_Surface *",
|
||||||
|
|
@ -317,6 +349,62 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_LoadPNG_IO",
|
||||||
|
"return_type": "SDL_Surface *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "closeio",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_LoadPNG",
|
||||||
|
"return_type": "SDL_Surface *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "file",
|
||||||
|
"type": "const char *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SavePNG_IO",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "surface",
|
||||||
|
"type": "SDL_Surface *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "SDL_IOStream *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "closeio",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SavePNG",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "surface",
|
||||||
|
"type": "SDL_Surface *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "file",
|
||||||
|
"type": "const char *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_SetSurfaceRLE",
|
"name": "SDL_SetSurfaceRLE",
|
||||||
"return_type": "bool",
|
"return_type": "bool",
|
||||||
|
|
@ -525,6 +613,20 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_RotateSurface",
|
||||||
|
"return_type": "SDL_Surface *",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "surface",
|
||||||
|
"type": "SDL_Surface *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "angle",
|
||||||
|
"type": "float"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_DuplicateSurface",
|
"name": "SDL_DuplicateSurface",
|
||||||
"return_type": "SDL_Surface *",
|
"return_type": "SDL_Surface *",
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,36 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_ProgressState",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"name": "SDL_PROGRESS_STATE_INVALID",
|
||||||
|
"value": "-1",
|
||||||
|
"comment": "An invalid progress state indicating an error; check SDL_GetError()"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PROGRESS_STATE_NONE",
|
||||||
|
"comment": "No progress bar is shown"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PROGRESS_STATE_INDETERMINATE",
|
||||||
|
"comment": "The progress bar is shown in a indeterminate state"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PROGRESS_STATE_NORMAL",
|
||||||
|
"comment": "The progress bar is shown in a normal state"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PROGRESS_STATE_PAUSED",
|
||||||
|
"comment": "The progress bar is shown in a paused state"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_PROGRESS_STATE_ERROR",
|
||||||
|
"comment": "The progress bar is shown in a state indicating the application had an error"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GLAttr",
|
"name": "SDL_GLAttr",
|
||||||
"values": [
|
"values": [
|
||||||
|
|
@ -222,7 +252,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GL_FRAMEBUFFER_SRGB_CAPABLE",
|
"name": "SDL_GL_FRAMEBUFFER_SRGB_CAPABLE",
|
||||||
"comment": "requests sRGB capable visual; defaults to 0."
|
"comment": "requests sRGB-capable visual if 1. Defaults to -1 (\"don't care\"). This is a request; GL drivers might not comply!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_GL_CONTEXT_RELEASE_BEHAVIOR",
|
"name": "SDL_GL_CONTEXT_RELEASE_BEHAVIOR",
|
||||||
|
|
@ -452,6 +482,11 @@
|
||||||
"value": "SDL_UINT64_C(0x0000000000100000)",
|
"value": "SDL_UINT64_C(0x0000000000100000)",
|
||||||
"comment": "window has grabbed keyboard input"
|
"comment": "window has grabbed keyboard input"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_WINDOW_FILL_DOCUMENT",
|
||||||
|
"value": "SDL_UINT64_C(0x0000000000200000)",
|
||||||
|
"comment": "window is in fill-document mode (Emscripten only), since SDL 3.4.0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_WINDOW_VULKAN",
|
"name": "SDL_WINDOW_VULKAN",
|
||||||
"value": "SDL_UINT64_C(0x0000000010000000)",
|
"value": "SDL_UINT64_C(0x0000000010000000)",
|
||||||
|
|
@ -1196,6 +1231,20 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetWindowFillDocument",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "window",
|
||||||
|
"type": "SDL_Window *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fill",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_ShowWindow",
|
"name": "SDL_ShowWindow",
|
||||||
"return_type": "bool",
|
"return_type": "bool",
|
||||||
|
|
@ -1573,6 +1622,54 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetWindowProgressState",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "window",
|
||||||
|
"type": "SDL_Window *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "state",
|
||||||
|
"type": "SDL_ProgressState"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetWindowProgressState",
|
||||||
|
"return_type": "SDL_ProgressState",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "window",
|
||||||
|
"type": "SDL_Window *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_SetWindowProgressValue",
|
||||||
|
"return_type": "bool",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "window",
|
||||||
|
"type": "SDL_Window *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "float"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SDL_GetWindowProgressValue",
|
||||||
|
"return_type": "float",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "window",
|
||||||
|
"type": "SDL_Window *"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SDL_DestroyWindow",
|
"name": "SDL_DestroyWindow",
|
||||||
"return_type": "void",
|
"return_type": "void",
|
||||||
|
|
|
||||||
176
src/codegen.zig
176
src/codegen.zig
|
|
@ -219,6 +219,78 @@ pub const CodeGen = struct {
|
||||||
try self.output.writer(self.allocator).print("pub const {s} = c.{s};\n\n", .{ zig_name, alias.name });
|
try self.output.writer(self.allocator).print("pub const {s} = c.{s};\n\n", .{ zig_name, alias.name });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn enumShouldBeFlags(self: *CodeGen, enum_decl: EnumDecl) !bool {
|
||||||
|
_ = self;
|
||||||
|
// Check if any enum value contains bitwise OR operator
|
||||||
|
for (enum_decl.values) |value| {
|
||||||
|
if (value.value) |val| {
|
||||||
|
if (std.mem.indexOf(u8, val, "|") != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn convertEnumToFlags(self: *CodeGen, enum_decl: EnumDecl) !FlagDecl {
|
||||||
|
// Convert numeric values to bit shift format and filter out invalid flags
|
||||||
|
var flags_list = std.ArrayList(patterns.FlagValue){};
|
||||||
|
errdefer flags_list.deinit(self.allocator);
|
||||||
|
|
||||||
|
// Track the current implicit value for enums
|
||||||
|
var implicit_value: u32 = 0;
|
||||||
|
|
||||||
|
for (enum_decl.values) |value| {
|
||||||
|
const current_value: ?u32 = if (value.value) |val| blk: {
|
||||||
|
// Has explicit value, try to parse it
|
||||||
|
const trimmed = std.mem.trim(u8, val, " \t");
|
||||||
|
|
||||||
|
// Skip combined values (contain |)
|
||||||
|
if (std.mem.indexOf(u8, trimmed, "|") != null) {
|
||||||
|
break :blk null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed = std.fmt.parseInt(u32, trimmed, 0) catch {
|
||||||
|
break :blk null;
|
||||||
|
};
|
||||||
|
implicit_value = parsed + 1;
|
||||||
|
break :blk parsed;
|
||||||
|
} else blk: {
|
||||||
|
// No explicit value, use implicit
|
||||||
|
const val = implicit_value;
|
||||||
|
implicit_value += 1;
|
||||||
|
break :blk val;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (current_value) |val| {
|
||||||
|
// Skip zero/NONE values
|
||||||
|
if (val == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it's a power of 2
|
||||||
|
if (val > 0 and (val & (val - 1)) == 0) {
|
||||||
|
// Calculate bit position
|
||||||
|
const bit_pos = @ctz(val);
|
||||||
|
const bit_shift_str = try std.fmt.allocPrint(self.allocator, "(1u << {d})", .{bit_pos});
|
||||||
|
|
||||||
|
try flags_list.append(self.allocator, .{
|
||||||
|
.name = try self.allocator.dupe(u8, value.name),
|
||||||
|
.value = bit_shift_str,
|
||||||
|
.comment = if (value.comment) |c| try self.allocator.dupe(u8, c) else null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FlagDecl{
|
||||||
|
.name = try self.allocator.dupe(u8, enum_decl.name),
|
||||||
|
.underlying_type = try self.allocator.dupe(u8, "Uint32"),
|
||||||
|
.flags = try flags_list.toOwnedSlice(self.allocator),
|
||||||
|
.doc_comment = if (enum_decl.doc_comment) |doc| try self.allocator.dupe(u8, doc) else null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn writeEnum(self: *CodeGen, enum_decl: EnumDecl) !void {
|
fn writeEnum(self: *CodeGen, enum_decl: EnumDecl) !void {
|
||||||
std.debug.print("enum {s} values.len = {d}\n", .{ enum_decl.name, enum_decl.values.len });
|
std.debug.print("enum {s} values.len = {d}\n", .{ enum_decl.name, enum_decl.values.len });
|
||||||
// Skip empty enums
|
// Skip empty enums
|
||||||
|
|
@ -226,6 +298,14 @@ pub const CodeGen = struct {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if this enum contains bitwise OR operations (making it a flags type)
|
||||||
|
const should_be_flags = try self.enumShouldBeFlags(enum_decl);
|
||||||
|
if (should_be_flags) {
|
||||||
|
const flag_decl = try self.convertEnumToFlags(enum_decl);
|
||||||
|
defer flag_decl.deinit(self.allocator);
|
||||||
|
return self.writeFlags(flag_decl);
|
||||||
|
}
|
||||||
|
|
||||||
const zig_name = naming.typeNameToZig(enum_decl.name);
|
const zig_name = naming.typeNameToZig(enum_decl.name);
|
||||||
|
|
||||||
// Write doc comment if present
|
// Write doc comment if present
|
||||||
|
|
@ -245,17 +325,105 @@ pub const CodeGen = struct {
|
||||||
const prefix = try naming.detectCommonPrefix(value_names, self.allocator);
|
const prefix = try naming.detectCommonPrefix(value_names, self.allocator);
|
||||||
defer self.allocator.free(prefix);
|
defer self.allocator.free(prefix);
|
||||||
|
|
||||||
// Write enum values
|
// First pass: build maps for resolving identifiers and tracking duplicates
|
||||||
|
var identifier_to_value = std.StringHashMap([]const u8).init(self.allocator);
|
||||||
|
defer identifier_to_value.deinit();
|
||||||
|
var value_to_name = std.StringHashMap([]const u8).init(self.allocator);
|
||||||
|
defer value_to_name.deinit();
|
||||||
|
|
||||||
for (enum_decl.values) |value| {
|
for (enum_decl.values) |value| {
|
||||||
|
if (value.value) |explicit_value| {
|
||||||
|
// Strip 'u' suffix if present
|
||||||
|
const clean_value = if (std.mem.endsWith(u8, explicit_value, "u"))
|
||||||
|
explicit_value[0..explicit_value.len - 1]
|
||||||
|
else
|
||||||
|
explicit_value;
|
||||||
|
|
||||||
|
try identifier_to_value.put(value.name, clean_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second pass: resolve identifier references and track numeric values
|
||||||
|
var resolved_values = try self.allocator.alloc(?[]const u8, enum_decl.values.len);
|
||||||
|
defer self.allocator.free(resolved_values);
|
||||||
|
|
||||||
|
for (enum_decl.values, 0..) |value, i| {
|
||||||
|
if (value.value) |explicit_value| {
|
||||||
|
const clean_value = if (std.mem.endsWith(u8, explicit_value, "u"))
|
||||||
|
explicit_value[0..explicit_value.len - 1]
|
||||||
|
else
|
||||||
|
explicit_value;
|
||||||
|
|
||||||
|
// Check if this is an identifier reference (no hex/digit prefix)
|
||||||
|
if (clean_value.len > 0 and !std.ascii.isDigit(clean_value[0])) {
|
||||||
|
// Try to resolve it
|
||||||
|
if (identifier_to_value.get(clean_value)) |numeric_value| {
|
||||||
|
resolved_values[i] = numeric_value;
|
||||||
|
} else {
|
||||||
|
// Can't resolve, use as-is (might be an error)
|
||||||
|
resolved_values[i] = clean_value;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolved_values[i] = clean_value;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolved_values[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Third pass: write enum values, tracking duplicates
|
||||||
|
const EnumAlias = struct { name: []const u8, target: []const u8, comment: ?[]const u8 };
|
||||||
|
var aliases = std.ArrayList(EnumAlias){};
|
||||||
|
defer aliases.deinit(self.allocator);
|
||||||
|
|
||||||
|
for (enum_decl.values, 0..) |value, i| {
|
||||||
const zig_value = try naming.enumValueToZig(value.name, prefix, self.allocator);
|
const zig_value = try naming.enumValueToZig(value.name, prefix, self.allocator);
|
||||||
defer self.allocator.free(zig_value);
|
defer self.allocator.free(zig_value);
|
||||||
|
|
||||||
|
if (resolved_values[i]) |numeric_value| {
|
||||||
|
// Check if this numeric value already exists
|
||||||
|
if (value_to_name.get(numeric_value)) |first_name| {
|
||||||
|
// This is a duplicate, save as alias
|
||||||
|
const first_zig = try naming.enumValueToZig(first_name, prefix, self.allocator);
|
||||||
|
try aliases.append(self.allocator, .{
|
||||||
|
.name = try self.allocator.dupe(u8, zig_value),
|
||||||
|
.target = first_zig,
|
||||||
|
.comment = if (value.comment) |c| try self.allocator.dupe(u8, c) else null
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// First occurrence of this value
|
||||||
|
try value_to_name.put(numeric_value, value.name);
|
||||||
|
|
||||||
|
if (value.comment) |comment| {
|
||||||
|
try self.output.writer(self.allocator).print(" {s} = {s}, //{s}\n", .{ zig_value, numeric_value, comment });
|
||||||
|
} else {
|
||||||
|
try self.output.writer(self.allocator).print(" {s} = {s},\n", .{ zig_value, numeric_value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No explicit value
|
||||||
if (value.comment) |comment| {
|
if (value.comment) |comment| {
|
||||||
try self.output.writer(self.allocator).print(" {s}, //{s}\n", .{ zig_value, comment });
|
try self.output.writer(self.allocator).print(" {s}, //{s}\n", .{ zig_value, comment });
|
||||||
} else {
|
} else {
|
||||||
try self.output.writer(self.allocator).print(" {s},\n", .{zig_value});
|
try self.output.writer(self.allocator).print(" {s},\n", .{zig_value});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write aliases as pub const inside the enum
|
||||||
|
if (aliases.items.len > 0) {
|
||||||
|
try self.output.appendSlice(self.allocator, "\n");
|
||||||
|
for (aliases.items) |alias| {
|
||||||
|
if (alias.comment) |comment| {
|
||||||
|
try self.output.writer(self.allocator).print(" pub const {s} = .{s}; //{s}\n", .{ alias.name, alias.target, comment });
|
||||||
|
} else {
|
||||||
|
try self.output.writer(self.allocator).print(" pub const {s} = .{s};\n", .{ alias.name, alias.target });
|
||||||
|
}
|
||||||
|
self.allocator.free(alias.name);
|
||||||
|
self.allocator.free(alias.target);
|
||||||
|
if (alias.comment) |c| self.allocator.free(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try self.output.appendSlice(self.allocator, "};\n\n");
|
try self.output.appendSlice(self.allocator, "};\n\n");
|
||||||
}
|
}
|
||||||
|
|
@ -403,7 +571,11 @@ pub const CodeGen = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always add a reserved bit at the end
|
// Always add a reserved bit at the end
|
||||||
try self.output.appendSlice(self.allocator, " rsvd: bool = false,\n");
|
try self.output.appendSlice(self.allocator, " rsvd: bool = false,\n\n");
|
||||||
|
|
||||||
|
// Add None constant for zero value (C header parity)
|
||||||
|
try self.output.writer(self.allocator).print(" pub const None = {s}{{}};\n", .{zig_name});
|
||||||
|
|
||||||
try self.output.appendSlice(self.allocator, "};\n\n");
|
try self.output.appendSlice(self.allocator, "};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,20 @@ pub fn convertType(c_type: []const u8, allocator: Allocator) ![]const u8 {
|
||||||
|
|
||||||
/// Determine the appropriate cast for a given type when calling C functions
|
/// Determine the appropriate cast for a given type when calling C functions
|
||||||
pub fn getCastType(zig_type: []const u8) CastType {
|
pub fn getCastType(zig_type: []const u8) CastType {
|
||||||
// Opaque pointers need @ptrCast
|
// Bool needs @bitCast
|
||||||
if (std.mem.startsWith(u8, zig_type, "*") and !std.mem.startsWith(u8, zig_type, "*anyopaque")) {
|
if (std.mem.eql(u8, zig_type, "bool")) {
|
||||||
|
return .bit_cast;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Opaque pointers need @ptrCast (both ?*Type and *Type)
|
||||||
|
// Skip [*c] (C pointers) and *anyopaque
|
||||||
|
if (std.mem.startsWith(u8, zig_type, "?*") or std.mem.startsWith(u8, zig_type, "*")) {
|
||||||
|
// Exclude anyopaque and C pointers
|
||||||
|
if (std.mem.indexOf(u8, zig_type, "anyopaque") != null or
|
||||||
|
std.mem.startsWith(u8, zig_type, "[*c]") or
|
||||||
|
std.mem.startsWith(u8, zig_type, "?[*c]")) {
|
||||||
|
return .none;
|
||||||
|
}
|
||||||
return .ptr_cast;
|
return .ptr_cast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue