238 lines
8.8 KiB
Zig
238 lines
8.8 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) {
|
|
pixelformatYv12, //Planar mode: Y + V + U (3 planes)
|
|
pixelformatIyuv, //Planar mode: Y + U + V (3 planes)
|
|
pixelformatYuy2, //Packed mode: Y0+U0+Y1+V0 (1 plane)
|
|
pixelformatUyvy, //Packed mode: U0+Y0+V0+Y1 (1 plane)
|
|
pixelformatYvyu, //Packed mode: Y0+V0+Y1+U0 (1 plane)
|
|
pixelformatNv12, //Planar mode: Y + U/V interleaved (2 planes)
|
|
pixelformatNv21, //Planar mode: Y + V/U interleaved (2 planes)
|
|
pixelformatP010, //Planar mode: Y + U/V interleaved (2 planes)
|
|
pixelformatExternalOes, //Android video texture format
|
|
};
|
|
|
|
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
|
|
colorRangeFull,
|
|
};
|
|
|
|
pub const ColorPrimaries = enum(c_int) {
|
|
colorPrimariesBt709, //ITU-R BT.709-6
|
|
colorPrimariesBt470m, //ITU-R BT.470-6 System M
|
|
colorPrimariesBt470bg, //ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625
|
|
colorPrimariesBt601, //ITU-R BT.601-7 525, SMPTE 170M
|
|
colorPrimariesSmpte240, //SMPTE 240M, functionally the same as SDL_COLOR_PRIMARIES_BT601
|
|
colorPrimariesGenericFilm, //Generic film (color filters using Illuminant C)
|
|
colorPrimariesBt2020, //ITU-R BT.2020-2 / ITU-R BT.2100-0
|
|
colorPrimariesXyz, //SMPTE ST 428-1
|
|
colorPrimariesSmpte431, //SMPTE RP 431-2
|
|
colorPrimariesSmpte432, //SMPTE EG 432-1 / DCI P3
|
|
colorPrimariesEbu3213, //EBU Tech. 3213-E
|
|
};
|
|
|
|
pub const TransferCharacteristics = enum(c_int) {
|
|
transferCharacteristicsBt709, //Rec. ITU-R BT.709-6 / ITU-R BT1361
|
|
transferCharacteristicsGamma22, //ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM
|
|
transferCharacteristicsGamma28, //ITU-R BT.470-6 System B, G
|
|
transferCharacteristicsBt601, //SMPTE ST 170M / ITU-R BT.601-7 525 or 625
|
|
transferCharacteristicsSmpte240, //SMPTE ST 240M
|
|
transferCharacteristicsIec61966, //IEC 61966-2-4
|
|
transferCharacteristicsBt1361, //ITU-R BT1361 Extended Colour Gamut
|
|
transferCharacteristicsSrgb, //IEC 61966-2-1 (sRGB or sYCC)
|
|
transferCharacteristicsBt202010bit, //ITU-R BT2020 for 10-bit system
|
|
transferCharacteristicsBt202012bit, //ITU-R BT2020 for 12-bit system
|
|
transferCharacteristicsPq, //SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
|
|
transferCharacteristicsSmpte428, //SMPTE ST 428-1
|
|
transferCharacteristicsHlg, //ARIB STD-B67, known as "hybrid log-gamma" (HLG)
|
|
};
|
|
|
|
pub const MatrixCoefficients = enum(c_int) {
|
|
matrixCoefficientsBt709, //ITU-R BT.709-6
|
|
matrixCoefficientsFcc, //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
|
|
matrixCoefficientsBt601, //ITU-R BT.601-7 525
|
|
matrixCoefficientsSmpte240, //SMPTE 240M
|
|
matrixCoefficientsBt2020Ncl, //ITU-R BT.2020-2 non-constant luminance
|
|
matrixCoefficientsBt2020Cl, //ITU-R BT.2020-2 constant luminance
|
|
matrixCoefficientsSmpte2085, //SMPTE ST 2085
|
|
matrixCoefficientsIctcp, //ITU-R BT.2100-0 ICTCP
|
|
};
|
|
|
|
pub const ChromaLocation = enum(c_int) {
|
|
chromaLocationNone, //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.
|
|
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.
|
|
chromaLocationTopleft,
|
|
};
|
|
|
|
pub const Colorspace = enum(c_int) {
|
|
colorspaceSrgb, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
|
|
colorRangeFull,
|
|
colorPrimariesBt709,
|
|
transferCharacteristicsSrgb,
|
|
matrixCoefficientsIdentity,
|
|
colorspaceSrgbLinear, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
|
|
transferCharacteristicsLinear,
|
|
colorspaceHdr10, //Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
|
|
colorPrimariesBt2020,
|
|
transferCharacteristicsPq,
|
|
colorspaceJpeg, //Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
|
|
transferCharacteristicsBt601,
|
|
matrixCoefficientsBt601,
|
|
colorspaceBt601Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
|
colorRangeLimited,
|
|
colorPrimariesBt601,
|
|
colorspaceBt601Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
|
|
colorspaceBt709Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
|
transferCharacteristicsBt709,
|
|
matrixCoefficientsBt709,
|
|
colorspaceBt709Full, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
|
|
colorspaceBt2020Limited, //Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
|
|
matrixCoefficientsBt2020Ncl,
|
|
colorspaceBt2020Full, //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 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);
|
|
}
|