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