156 lines
4.2 KiB
Zig
156 lines
4.2 KiB
Zig
const std = @import("std");
|
|
pub const c = @import("c.zig").c;
|
|
|
|
pub const PixelFormat = enum(c_int) {
|
|
pixelformatUnknown,
|
|
pixelformatIndex1lsb,
|
|
pixelformatIndex1msb,
|
|
pixelformatIndex2lsb,
|
|
pixelformatIndex2msb,
|
|
pixelformatIndex4lsb,
|
|
pixelformatIndex4msb,
|
|
pixelformatIndex8,
|
|
pixelformatRgb332,
|
|
pixelformatXrgb4444,
|
|
pixelformatXbgr4444,
|
|
pixelformatXrgb1555,
|
|
pixelformatXbgr1555,
|
|
pixelformatArgb4444,
|
|
pixelformatRgba4444,
|
|
pixelformatAbgr4444,
|
|
pixelformatBgra4444,
|
|
pixelformatArgb1555,
|
|
pixelformatRgba5551,
|
|
pixelformatAbgr1555,
|
|
pixelformatBgra5551,
|
|
pixelformatRgb565,
|
|
pixelformatBgr565,
|
|
pixelformatRgb24,
|
|
pixelformatBgr24,
|
|
pixelformatXrgb8888,
|
|
pixelformatRgbx8888,
|
|
pixelformatXbgr8888,
|
|
pixelformatBgrx8888,
|
|
pixelformatArgb8888,
|
|
pixelformatRgba8888,
|
|
pixelformatAbgr8888,
|
|
pixelformatBgra8888,
|
|
pixelformatXrgb2101010,
|
|
pixelformatXbgr2101010,
|
|
pixelformatArgb2101010,
|
|
pixelformatAbgr2101010,
|
|
pixelformatRgb48,
|
|
pixelformatBgr48,
|
|
pixelformatRgba64,
|
|
pixelformatArgb64,
|
|
pixelformatBgra64,
|
|
pixelformatAbgr64,
|
|
pixelformatRgb48Float,
|
|
pixelformatBgr48Float,
|
|
pixelformatRgba64Float,
|
|
pixelformatArgb64Float,
|
|
pixelformatBgra64Float,
|
|
pixelformatAbgr64Float,
|
|
pixelformatRgb96Float,
|
|
pixelformatBgr96Float,
|
|
pixelformatRgba128Float,
|
|
pixelformatArgb128Float,
|
|
pixelformatBgra128Float,
|
|
pixelformatAbgr128Float,
|
|
pixelformatRgba32,
|
|
pixelformatArgb32,
|
|
pixelformatBgra32,
|
|
pixelformatAbgr32,
|
|
pixelformatRgbx32,
|
|
pixelformatXrgb32,
|
|
pixelformatBgrx32,
|
|
pixelformatXbgr32,
|
|
};
|
|
|
|
pub const Surface = opaque {};
|
|
|
|
pub const Colorspace = enum(c_int) {
|
|
colorspaceUnknown,
|
|
};
|
|
|
|
pub const PropertiesID = u32;
|
|
|
|
pub const CameraID = u32;
|
|
|
|
pub const Camera = opaque {
|
|
pub inline fn getCameraPermissionState(camera: *Camera) c_int {
|
|
return c.SDL_GetCameraPermissionState(camera);
|
|
}
|
|
|
|
pub inline fn getCameraID(camera: *Camera) CameraID {
|
|
return c.SDL_GetCameraID(camera);
|
|
}
|
|
|
|
pub inline fn getCameraProperties(camera: *Camera) PropertiesID {
|
|
return c.SDL_GetCameraProperties(camera);
|
|
}
|
|
|
|
pub inline fn getCameraFormat(camera: *Camera, spec: ?*CameraSpec) bool {
|
|
return c.SDL_GetCameraFormat(camera, spec);
|
|
}
|
|
|
|
pub inline fn acquireCameraFrame(camera: *Camera, timestampNS: *u64) ?*Surface {
|
|
return c.SDL_AcquireCameraFrame(camera, @ptrCast(timestampNS));
|
|
}
|
|
|
|
pub inline fn releaseCameraFrame(camera: *Camera, frame: ?*Surface) void {
|
|
return c.SDL_ReleaseCameraFrame(camera, frame);
|
|
}
|
|
|
|
pub inline fn closeCamera(camera: *Camera) void {
|
|
return c.SDL_CloseCamera(camera);
|
|
}
|
|
};
|
|
|
|
pub const CameraSpec = extern struct {
|
|
format: PixelFormat, // Frame format
|
|
colorspace: Colorspace, // Frame colorspace
|
|
width: c_int, // Frame width
|
|
height: c_int, // Frame height
|
|
framerate_numerator: c_int, // Frame rate numerator ((num / denom) == FPS, (denom / num) == duration in seconds)
|
|
framerate_denominator: c_int, // Frame rate demoninator ((num / denom) == FPS, (denom / num) == duration in seconds)
|
|
};
|
|
|
|
pub const CameraPosition = enum(c_int) {
|
|
cameraPositionUnknown,
|
|
cameraPositionFrontFacing,
|
|
cameraPositionBackFacing,
|
|
};
|
|
|
|
pub inline fn getNumCameraDrivers() c_int {
|
|
return c.SDL_GetNumCameraDrivers();
|
|
}
|
|
|
|
pub inline fn getCameraDriver(index: c_int) [*c]const u8 {
|
|
return c.SDL_GetCameraDriver(index);
|
|
}
|
|
|
|
pub inline fn getCurrentCameraDriver() [*c]const u8 {
|
|
return c.SDL_GetCurrentCameraDriver();
|
|
}
|
|
|
|
pub inline fn getCameras(count: *c_int) ?*CameraID {
|
|
return c.SDL_GetCameras(@ptrCast(count));
|
|
}
|
|
|
|
pub inline fn getCameraSupportedFormats(instance_id: CameraID, count: *c_int) [*c][*c]CameraSpec {
|
|
return c.SDL_GetCameraSupportedFormats(instance_id, @ptrCast(count));
|
|
}
|
|
|
|
pub inline fn getCameraName(instance_id: CameraID) [*c]const u8 {
|
|
return c.SDL_GetCameraName(instance_id);
|
|
}
|
|
|
|
pub inline fn getCameraPosition(instance_id: CameraID) CameraPosition {
|
|
return c.SDL_GetCameraPosition(instance_id);
|
|
}
|
|
|
|
pub inline fn openCamera(instance_id: CameraID, spec: *const CameraSpec) ?*Camera {
|
|
return c.SDL_OpenCamera(instance_id, @ptrCast(spec));
|
|
}
|