const std = @import("std"); pub const c = @import("c.zig").c; const rect_api = @import("rect.zig"); const pixels_api = @import("pixels.zig"); const surface_api = @import("surface.zig"); const properties_api = @import("properties.zig"); const video_api = @import("video.zig"); const gpu_api = @import("gpu.zig"); const blendmode_api = @import("blendmode.zig"); const events_api = @import("events.zig"); const joystick_api = @import("joystick.zig"); const mouse_api = @import("mouse.zig"); const pen_api = @import("pen.zig"); const camera_api = @import("camera.zig"); const keyboard_api = @import("keyboard.zig"); const power_api = @import("power.zig"); const touch_api = @import("touch.zig"); const sensor_api = @import("sensor.zig"); const audio_api = @import("audio.zig"); const scancode_api = @import("scancode.zig"); const keycode_api = @import("keycode.zig"); pub const FPoint = rect_api.FPoint; pub const FColor = pixels_api.FColor; pub const Surface = surface_api.Surface; pub const PropertiesID = properties_api.PropertiesID; pub const Window = video_api.Window; pub const FRect = rect_api.FRect; pub const GPUTextureSamplerBinding = gpu_api.GPUTextureSamplerBinding; pub const GPUSampler = gpu_api.GPUSampler; pub const GPUTexture = gpu_api.GPUTexture; pub const GPUShader = gpu_api.GPUShader; pub const WindowFlags = video_api.WindowFlags; pub const PixelFormat = pixels_api.PixelFormat; pub const ScaleMode = surface_api.ScaleMode; pub const GPUDevice = gpu_api.GPUDevice; pub const BlendMode = blendmode_api.BlendMode; pub const Event = events_api.Event; pub const JoyAxisEvent = events_api.JoyAxisEvent; pub const UserEvent = events_api.UserEvent; pub const PinchFingerEvent = events_api.PinchFingerEvent; pub const MouseMotionEvent = events_api.MouseMotionEvent; pub const CommonEvent = events_api.CommonEvent; pub const GamepadButtonEvent = events_api.GamepadButtonEvent; pub const JoyDeviceEvent = events_api.JoyDeviceEvent; pub const GamepadTouchpadEvent = events_api.GamepadTouchpadEvent; pub const GamepadSensorEvent = events_api.GamepadSensorEvent; pub const RenderEvent = events_api.RenderEvent; pub const ClipboardEvent = events_api.ClipboardEvent; pub const PenMotionEvent = events_api.PenMotionEvent; pub const GamepadAxisEvent = events_api.GamepadAxisEvent; pub const DisplayEvent = events_api.DisplayEvent; pub const DropEvent = events_api.DropEvent; pub const CameraDeviceEvent = events_api.CameraDeviceEvent; pub const KeyboardDeviceEvent = events_api.KeyboardDeviceEvent; pub const JoyBatteryEvent = events_api.JoyBatteryEvent; pub const TouchFingerEvent = events_api.TouchFingerEvent; pub const SensorEvent = events_api.SensorEvent; pub const TextEditingEvent = events_api.TextEditingEvent; pub const JoyHatEvent = events_api.JoyHatEvent; pub const QuitEvent = events_api.QuitEvent; pub const PenProximityEvent = events_api.PenProximityEvent; pub const WindowEvent = events_api.WindowEvent; pub const PenTouchEvent = events_api.PenTouchEvent; pub const PenButtonEvent = events_api.PenButtonEvent; pub const GamepadDeviceEvent = events_api.GamepadDeviceEvent; pub const JoyBallEvent = events_api.JoyBallEvent; pub const AudioDeviceEvent = events_api.AudioDeviceEvent; pub const MouseWheelEvent = events_api.MouseWheelEvent; pub const PenAxisEvent = events_api.PenAxisEvent; pub const MouseDeviceEvent = events_api.MouseDeviceEvent; pub const JoyButtonEvent = events_api.JoyButtonEvent; pub const MouseButtonEvent = events_api.MouseButtonEvent; pub const KeyboardEvent = events_api.KeyboardEvent; pub const TextEditingCandidatesEvent = events_api.TextEditingCandidatesEvent; pub const TextInputEvent = events_api.TextInputEvent; pub const EventType = events_api.EventType; pub const JoystickID = joystick_api.JoystickID; pub const WindowID = video_api.WindowID; pub const MouseID = mouse_api.MouseID; pub const MouseButtonFlags = mouse_api.MouseButtonFlags; pub const PenInputFlags = pen_api.PenInputFlags; pub const PenID = pen_api.PenID; pub const DisplayID = video_api.DisplayID; pub const CameraID = camera_api.CameraID; pub const KeyboardID = keyboard_api.KeyboardID; pub const PowerState = power_api.PowerState; pub const TouchID = touch_api.TouchID; pub const FingerID = touch_api.FingerID; pub const SensorID = sensor_api.SensorID; pub const AudioDeviceID = audio_api.AudioDeviceID; pub const MouseWheelDirection = mouse_api.MouseWheelDirection; pub const PenAxis = pen_api.PenAxis; pub const Scancode = scancode_api.Scancode; pub const Keymod = keycode_api.Keymod; pub const Keycode = keycode_api.Keycode; pub const FlipMode = surface_api.FlipMode; pub const GPUBuffer = gpu_api.GPUBuffer; pub const Rect = rect_api.Rect; pub const Palette = pixels_api.Palette; pub const Color = pixels_api.Color; pub const Vertex = extern struct { position: FPoint, // Vertex position, in SDL_Renderer coordinates color: FColor, // Vertex color tex_coord: FPoint, // Normalized texture coordinates, if needed }; pub const TextureAccess = enum(c_int) { textureaccessStatic, //Changes rarely, not lockable textureaccessStreaming, //Changes frequently, lockable textureaccessTarget, //Texture can be used as a render target }; pub const TextureAddressMode = enum(c_int) { textureAddressAuto, //Wrapping is enabled if texture coordinates are outside [0, 1], this is the default textureAddressClamp, //Texture coordinates are clamped to the [0, 1] range textureAddressWrap, //The texture is repeated (tiled) }; pub const RendererLogicalPresentation = enum(c_int) { logicalPresentationDisabled, //There is no logical size in effect logicalPresentationStretch, //The rendered content is stretched to the output resolution logicalPresentationLetterbox, //The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color logicalPresentationOverscan, //The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds logicalPresentationIntegerScale, //The rendered content is scaled up by integer multiples to fit the output resolution }; pub const Renderer = opaque { pub inline fn getGPURendererDevice(renderer: *Renderer) ?*GPUDevice { return @ptrCast(c.SDL_GetGPURendererDevice(@ptrCast(renderer))); } pub inline fn getRenderWindow(renderer: *Renderer) ?*Window { return @ptrCast(c.SDL_GetRenderWindow(@ptrCast(renderer))); } pub inline fn getRendererName(renderer: *Renderer) [*c]const u8 { return c.SDL_GetRendererName(@ptrCast(renderer)); } pub inline fn getRendererProperties(renderer: *Renderer) PropertiesID { return c.SDL_GetRendererProperties(@ptrCast(renderer)); } pub inline fn getRenderOutputSize(renderer: *Renderer, w: *c_int, h: *c_int) bool { return @bitCast(c.SDL_GetRenderOutputSize(@ptrCast(renderer), @ptrCast(w), @ptrCast(h))); } pub inline fn getCurrentRenderOutputSize(renderer: *Renderer, w: *c_int, h: *c_int) bool { return @bitCast(c.SDL_GetCurrentRenderOutputSize(@ptrCast(renderer), @ptrCast(w), @ptrCast(h))); } pub inline fn createTexture(renderer: *Renderer, format: PixelFormat, access: TextureAccess, w: c_int, h: c_int) ?*Texture { return @ptrCast(c.SDL_CreateTexture(@ptrCast(renderer), @bitCast(format), access, w, h)); } pub inline fn createTextureFromSurface(renderer: *Renderer, surface: ?*Surface) ?*Texture { return @ptrCast(c.SDL_CreateTextureFromSurface(@ptrCast(renderer), @ptrCast(surface))); } pub inline fn createTextureWithProperties(renderer: *Renderer, props: PropertiesID) ?*Texture { return @ptrCast(c.SDL_CreateTextureWithProperties(@ptrCast(renderer), props)); } pub inline fn setRenderTarget(renderer: *Renderer, texture: ?*Texture) bool { return @bitCast(c.SDL_SetRenderTarget(@ptrCast(renderer), @ptrCast(texture))); } pub inline fn getRenderTarget(renderer: *Renderer) ?*Texture { return @ptrCast(c.SDL_GetRenderTarget(@ptrCast(renderer))); } pub inline fn setRenderLogicalPresentation(renderer: *Renderer, w: c_int, h: c_int, mode: RendererLogicalPresentation) bool { return @bitCast(c.SDL_SetRenderLogicalPresentation(@ptrCast(renderer), w, h, mode)); } pub inline fn getRenderLogicalPresentation(renderer: *Renderer, w: *c_int, h: *c_int, mode: ?*RendererLogicalPresentation) bool { return @bitCast(c.SDL_GetRenderLogicalPresentation(@ptrCast(renderer), @ptrCast(w), @ptrCast(h), @ptrCast(mode))); } pub inline fn getRenderLogicalPresentationRect(renderer: *Renderer, rect: ?*FRect) bool { return @bitCast(c.SDL_GetRenderLogicalPresentationRect(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn renderCoordinatesFromWindow(renderer: *Renderer, window_x: f32, window_y: f32, x: *f32, y: *f32) bool { return @bitCast(c.SDL_RenderCoordinatesFromWindow(@ptrCast(renderer), window_x, window_y, @ptrCast(x), @ptrCast(y))); } pub inline fn renderCoordinatesToWindow(renderer: *Renderer, x: f32, y: f32, window_x: *f32, window_y: *f32) bool { return @bitCast(c.SDL_RenderCoordinatesToWindow(@ptrCast(renderer), x, y, @ptrCast(window_x), @ptrCast(window_y))); } pub inline fn convertEventToRenderCoordinates(renderer: *Renderer, event: ?*Event) bool { return @bitCast(c.SDL_ConvertEventToRenderCoordinates(@ptrCast(renderer), @ptrCast(event))); } pub inline fn setRenderViewport(renderer: *Renderer, rect: ?*const Rect) bool { return @bitCast(c.SDL_SetRenderViewport(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn getRenderViewport(renderer: *Renderer, rect: ?*Rect) bool { return @bitCast(c.SDL_GetRenderViewport(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn renderViewportSet(renderer: *Renderer) bool { return @bitCast(c.SDL_RenderViewportSet(@ptrCast(renderer))); } pub inline fn getRenderSafeArea(renderer: *Renderer, rect: ?*Rect) bool { return @bitCast(c.SDL_GetRenderSafeArea(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn setRenderClipRect(renderer: *Renderer, rect: ?*const Rect) bool { return @bitCast(c.SDL_SetRenderClipRect(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn getRenderClipRect(renderer: *Renderer, rect: ?*Rect) bool { return @bitCast(c.SDL_GetRenderClipRect(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn renderClipEnabled(renderer: *Renderer) bool { return @bitCast(c.SDL_RenderClipEnabled(@ptrCast(renderer))); } pub inline fn setRenderScale(renderer: *Renderer, scaleX: f32, scaleY: f32) bool { return @bitCast(c.SDL_SetRenderScale(@ptrCast(renderer), scaleX, scaleY)); } pub inline fn getRenderScale(renderer: *Renderer, scaleX: *f32, scaleY: *f32) bool { return @bitCast(c.SDL_GetRenderScale(@ptrCast(renderer), @ptrCast(scaleX), @ptrCast(scaleY))); } pub inline fn setRenderDrawColor(renderer: *Renderer, r: u8, g: u8, b: u8, a: u8) bool { return @bitCast(c.SDL_SetRenderDrawColor(@ptrCast(renderer), r, g, b, a)); } pub inline fn setRenderDrawColorFloat(renderer: *Renderer, r: f32, g: f32, b: f32, a: f32) bool { return @bitCast(c.SDL_SetRenderDrawColorFloat(@ptrCast(renderer), r, g, b, a)); } pub inline fn getRenderDrawColor(renderer: *Renderer, r: [*c]u8, g: [*c]u8, b: [*c]u8, a: [*c]u8) bool { return @bitCast(c.SDL_GetRenderDrawColor(@ptrCast(renderer), r, g, b, a)); } pub inline fn getRenderDrawColorFloat(renderer: *Renderer, r: *f32, g: *f32, b: *f32, a: *f32) bool { return @bitCast(c.SDL_GetRenderDrawColorFloat(@ptrCast(renderer), @ptrCast(r), @ptrCast(g), @ptrCast(b), @ptrCast(a))); } pub inline fn setRenderColorScale(renderer: *Renderer, scale: f32) bool { return @bitCast(c.SDL_SetRenderColorScale(@ptrCast(renderer), scale)); } pub inline fn getRenderColorScale(renderer: *Renderer, scale: *f32) bool { return @bitCast(c.SDL_GetRenderColorScale(@ptrCast(renderer), @ptrCast(scale))); } pub inline fn setRenderDrawBlendMode(renderer: *Renderer, blendMode: BlendMode) bool { return @bitCast(c.SDL_SetRenderDrawBlendMode(@ptrCast(renderer), @intFromEnum(blendMode))); } pub inline fn getRenderDrawBlendMode(renderer: *Renderer, blendMode: ?*BlendMode) bool { return @bitCast(c.SDL_GetRenderDrawBlendMode(@ptrCast(renderer), @ptrCast(blendMode))); } pub inline fn renderClear(renderer: *Renderer) bool { return @bitCast(c.SDL_RenderClear(@ptrCast(renderer))); } pub inline fn renderPoint(renderer: *Renderer, x: f32, y: f32) bool { return @bitCast(c.SDL_RenderPoint(@ptrCast(renderer), x, y)); } pub inline fn renderPoints(renderer: *Renderer, points: ?*const FPoint, count: c_int) bool { return @bitCast(c.SDL_RenderPoints(@ptrCast(renderer), @ptrCast(points), count)); } pub inline fn renderLine(renderer: *Renderer, x1: f32, y1: f32, x2: f32, y2: f32) bool { return @bitCast(c.SDL_RenderLine(@ptrCast(renderer), x1, y1, x2, y2)); } pub inline fn renderLines(renderer: *Renderer, points: ?*const FPoint, count: c_int) bool { return @bitCast(c.SDL_RenderLines(@ptrCast(renderer), @ptrCast(points), count)); } pub inline fn renderRect(renderer: *Renderer, rect: ?*const FRect) bool { return @bitCast(c.SDL_RenderRect(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn renderRects(renderer: *Renderer, rects: ?*const FRect, count: c_int) bool { return @bitCast(c.SDL_RenderRects(@ptrCast(renderer), @ptrCast(rects), count)); } pub inline fn renderFillRect(renderer: *Renderer, rect: ?*const FRect) bool { return @bitCast(c.SDL_RenderFillRect(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn renderFillRects(renderer: *Renderer, rects: ?*const FRect, count: c_int) bool { return @bitCast(c.SDL_RenderFillRects(@ptrCast(renderer), @ptrCast(rects), count)); } pub inline fn renderTexture(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, dstrect: ?*const FRect) bool { return @bitCast(c.SDL_RenderTexture(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(dstrect))); } pub inline fn renderTextureRotated(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, dstrect: ?*const FRect, angle: f64, center: ?*const FPoint, flip: FlipMode) bool { return @bitCast(c.SDL_RenderTextureRotated(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(dstrect), angle, @ptrCast(center), @intFromEnum(flip))); } pub inline fn renderTextureAffine(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, origin: ?*const FPoint, right: ?*const FPoint, down: ?*const FPoint) bool { return @bitCast(c.SDL_RenderTextureAffine(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), @ptrCast(origin), @ptrCast(right), @ptrCast(down))); } pub inline fn renderTextureTiled(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, scale: f32, dstrect: ?*const FRect) bool { return @bitCast(c.SDL_RenderTextureTiled(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), scale, @ptrCast(dstrect))); } pub inline fn renderTexture9Grid(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: ?*const FRect) bool { return @bitCast(c.SDL_RenderTexture9Grid(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect))); } pub inline fn renderTexture9GridTiled(renderer: *Renderer, texture: ?*Texture, srcrect: ?*const FRect, left_width: f32, right_width: f32, top_height: f32, bottom_height: f32, scale: f32, dstrect: ?*const FRect, tileScale: f32) bool { return @bitCast(c.SDL_RenderTexture9GridTiled(@ptrCast(renderer), @ptrCast(texture), @ptrCast(srcrect), left_width, right_width, top_height, bottom_height, scale, @ptrCast(dstrect), tileScale)); } pub inline fn renderGeometry(renderer: *Renderer, texture: ?*Texture, vertices: ?*const Vertex, num_vertices: c_int, indices: [*c]const c_int, num_indices: c_int) bool { return @bitCast(c.SDL_RenderGeometry(@ptrCast(renderer), @ptrCast(texture), @ptrCast(vertices), num_vertices, indices, num_indices)); } pub inline fn renderGeometryRaw(renderer: *Renderer, texture: ?*Texture, xy: *const f32, xy_stride: c_int, color: ?*const FColor, color_stride: c_int, uv: *const f32, uv_stride: c_int, num_vertices: c_int, indices: ?*const anyopaque, num_indices: c_int, size_indices: c_int) bool { return @bitCast(c.SDL_RenderGeometryRaw(@ptrCast(renderer), @ptrCast(texture), @ptrCast(xy), xy_stride, @ptrCast(color), color_stride, @ptrCast(uv), uv_stride, num_vertices, indices, num_indices, size_indices)); } pub inline fn setRenderTextureAddressMode(renderer: *Renderer, u_mode: TextureAddressMode, v_mode: TextureAddressMode) bool { return @bitCast(c.SDL_SetRenderTextureAddressMode(@ptrCast(renderer), @intFromEnum(u_mode), @intFromEnum(v_mode))); } pub inline fn getRenderTextureAddressMode(renderer: *Renderer, u_mode: ?*TextureAddressMode, v_mode: ?*TextureAddressMode) bool { return @bitCast(c.SDL_GetRenderTextureAddressMode(@ptrCast(renderer), @ptrCast(u_mode), @ptrCast(v_mode))); } pub inline fn renderReadPixels(renderer: *Renderer, rect: ?*const Rect) ?*Surface { return @ptrCast(c.SDL_RenderReadPixels(@ptrCast(renderer), @ptrCast(rect))); } pub inline fn renderPresent(renderer: *Renderer) bool { return @bitCast(c.SDL_RenderPresent(@ptrCast(renderer))); } pub inline fn destroyRenderer(renderer: *Renderer) void { return c.SDL_DestroyRenderer(@ptrCast(renderer)); } pub inline fn flushRenderer(renderer: *Renderer) bool { return @bitCast(c.SDL_FlushRenderer(@ptrCast(renderer))); } pub inline fn getRenderMetalLayer(renderer: *Renderer) ?*anyopaque { return c.SDL_GetRenderMetalLayer(@ptrCast(renderer)); } pub inline fn getRenderMetalCommandEncoder(renderer: *Renderer) ?*anyopaque { return c.SDL_GetRenderMetalCommandEncoder(@ptrCast(renderer)); } pub inline fn addVulkanRenderSemaphores(renderer: *Renderer, wait_stage_mask: u32, wait_semaphore: i64, signal_semaphore: i64) bool { return @bitCast(c.SDL_AddVulkanRenderSemaphores(@ptrCast(renderer), wait_stage_mask, wait_semaphore, signal_semaphore)); } pub inline fn setRenderVSync(renderer: *Renderer, vsync: c_int) bool { return @bitCast(c.SDL_SetRenderVSync(@ptrCast(renderer), vsync)); } pub inline fn getRenderVSync(renderer: *Renderer, vsync: *c_int) bool { return @bitCast(c.SDL_GetRenderVSync(@ptrCast(renderer), @ptrCast(vsync))); } pub inline fn renderDebugText(renderer: *Renderer, x: f32, y: f32, str: [*c]const u8) bool { return @bitCast(c.SDL_RenderDebugText(@ptrCast(renderer), x, y, str)); } pub inline fn setDefaultTextureScaleMode(renderer: *Renderer, scale_mode: ScaleMode) bool { return @bitCast(c.SDL_SetDefaultTextureScaleMode(@ptrCast(renderer), @intFromEnum(scale_mode))); } pub inline fn getDefaultTextureScaleMode(renderer: *Renderer, scale_mode: ?*ScaleMode) bool { return @bitCast(c.SDL_GetDefaultTextureScaleMode(@ptrCast(renderer), @ptrCast(scale_mode))); } pub inline fn createGPURenderState(renderer: *Renderer, createinfo: ?*GPURenderStateCreateInfo) ?*GPURenderState { return @ptrCast(c.SDL_CreateGPURenderState(@ptrCast(renderer), @ptrCast(createinfo))); } pub inline fn setGPURenderState(renderer: *Renderer, state: ?*GPURenderState) bool { return @bitCast(c.SDL_SetGPURenderState(@ptrCast(renderer), @ptrCast(state))); } }; pub const Texture = opaque { pub inline fn getTextureProperties(texture: *Texture) PropertiesID { return c.SDL_GetTextureProperties(@ptrCast(texture)); } pub inline fn getRendererFromTexture(texture: *Texture) ?*Renderer { return @ptrCast(c.SDL_GetRendererFromTexture(@ptrCast(texture))); } pub inline fn getTextureSize(texture: *Texture, w: *f32, h: *f32) bool { return @bitCast(c.SDL_GetTextureSize(@ptrCast(texture), @ptrCast(w), @ptrCast(h))); } pub inline fn setTexturePalette(texture: *Texture, palette: ?*Palette) bool { return @bitCast(c.SDL_SetTexturePalette(@ptrCast(texture), @ptrCast(palette))); } pub inline fn getTexturePalette(texture: *Texture) ?*Palette { return @ptrCast(c.SDL_GetTexturePalette(@ptrCast(texture))); } pub inline fn setTextureColorMod(texture: *Texture, r: u8, g: u8, b: u8) bool { return @bitCast(c.SDL_SetTextureColorMod(@ptrCast(texture), r, g, b)); } pub inline fn setTextureColorModFloat(texture: *Texture, r: f32, g: f32, b: f32) bool { return @bitCast(c.SDL_SetTextureColorModFloat(@ptrCast(texture), r, g, b)); } pub inline fn getTextureColorMod(texture: *Texture, r: [*c]u8, g: [*c]u8, b: [*c]u8) bool { return @bitCast(c.SDL_GetTextureColorMod(@ptrCast(texture), r, g, b)); } pub inline fn getTextureColorModFloat(texture: *Texture, r: *f32, g: *f32, b: *f32) bool { return @bitCast(c.SDL_GetTextureColorModFloat(@ptrCast(texture), @ptrCast(r), @ptrCast(g), @ptrCast(b))); } pub inline fn setTextureAlphaMod(texture: *Texture, alpha: u8) bool { return @bitCast(c.SDL_SetTextureAlphaMod(@ptrCast(texture), alpha)); } pub inline fn setTextureAlphaModFloat(texture: *Texture, alpha: f32) bool { return @bitCast(c.SDL_SetTextureAlphaModFloat(@ptrCast(texture), alpha)); } pub inline fn getTextureAlphaMod(texture: *Texture, alpha: [*c]u8) bool { return @bitCast(c.SDL_GetTextureAlphaMod(@ptrCast(texture), alpha)); } pub inline fn getTextureAlphaModFloat(texture: *Texture, alpha: *f32) bool { return @bitCast(c.SDL_GetTextureAlphaModFloat(@ptrCast(texture), @ptrCast(alpha))); } pub inline fn setTextureBlendMode(texture: *Texture, blendMode: BlendMode) bool { return @bitCast(c.SDL_SetTextureBlendMode(@ptrCast(texture), @intFromEnum(blendMode))); } pub inline fn getTextureBlendMode(texture: *Texture, blendMode: ?*BlendMode) bool { return @bitCast(c.SDL_GetTextureBlendMode(@ptrCast(texture), @ptrCast(blendMode))); } pub inline fn setTextureScaleMode(texture: *Texture, scaleMode: ScaleMode) bool { return @bitCast(c.SDL_SetTextureScaleMode(@ptrCast(texture), @intFromEnum(scaleMode))); } pub inline fn getTextureScaleMode(texture: *Texture, scaleMode: ?*ScaleMode) bool { return @bitCast(c.SDL_GetTextureScaleMode(@ptrCast(texture), @ptrCast(scaleMode))); } pub inline fn updateTexture(texture: *Texture, rect: ?*const Rect, pixels: ?*const anyopaque, pitch: c_int) bool { return @bitCast(c.SDL_UpdateTexture(@ptrCast(texture), @ptrCast(rect), pixels, pitch)); } pub inline fn updateYUVTexture(texture: *Texture, rect: ?*const Rect, Yplane: [*c]const u8, Ypitch: c_int, Uplane: [*c]const u8, Upitch: c_int, Vplane: [*c]const u8, Vpitch: c_int) bool { return @bitCast(c.SDL_UpdateYUVTexture(@ptrCast(texture), @ptrCast(rect), Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch)); } pub inline fn updateNVTexture(texture: *Texture, rect: ?*const Rect, Yplane: [*c]const u8, Ypitch: c_int, UVplane: [*c]const u8, UVpitch: c_int) bool { return @bitCast(c.SDL_UpdateNVTexture(@ptrCast(texture), @ptrCast(rect), Yplane, Ypitch, UVplane, UVpitch)); } pub inline fn lockTexture(texture: *Texture, rect: ?*const Rect, pixels: [*c]?*anyopaque, pitch: *c_int) bool { return @bitCast(c.SDL_LockTexture(@ptrCast(texture), @ptrCast(rect), pixels, @ptrCast(pitch))); } pub inline fn lockTextureToSurface(texture: *Texture, rect: ?*const Rect, surface: [*c]?*Surface) bool { return @bitCast(c.SDL_LockTextureToSurface(@ptrCast(texture), @ptrCast(rect), surface)); } pub inline fn unlockTexture(texture: *Texture) void { return c.SDL_UnlockTexture(@ptrCast(texture)); } pub inline fn destroyTexture(texture: *Texture) void { return c.SDL_DestroyTexture(@ptrCast(texture)); } }; pub inline fn getNumRenderDrivers() c_int { return c.SDL_GetNumRenderDrivers(); } pub inline fn getRenderDriver(index: c_int) [*c]const u8 { return c.SDL_GetRenderDriver(index); } pub inline fn createWindowAndRenderer(title: [*c]const u8, width: c_int, height: c_int, window_flags: WindowFlags, window: [*c]?*Window, renderer: [*c]?*Renderer) bool { return @bitCast(c.SDL_CreateWindowAndRenderer(title, width, height, @bitCast(window_flags), window, renderer)); } pub inline fn createRenderer(window: ?*Window, name: [*c]const u8) ?*Renderer { return @ptrCast(c.SDL_CreateRenderer(@ptrCast(window), name)); } pub inline fn createRendererWithProperties(props: PropertiesID) ?*Renderer { return @ptrCast(c.SDL_CreateRendererWithProperties(props)); } pub inline fn createGPURenderer(device: ?*GPUDevice, window: ?*Window) ?*Renderer { return @ptrCast(c.SDL_CreateGPURenderer(@ptrCast(device), @ptrCast(window))); } pub inline fn createSoftwareRenderer(surface: ?*Surface) ?*Renderer { return @ptrCast(c.SDL_CreateSoftwareRenderer(@ptrCast(surface))); } pub inline fn getRenderer(window: ?*Window) ?*Renderer { return @ptrCast(c.SDL_GetRenderer(@ptrCast(window))); } pub const GPURenderStateCreateInfo = extern struct { fragment_shader: ?*GPUShader, // The fragment shader to use when this render state is active num_sampler_bindings: i32, // The number of additional fragment samplers to bind when this render state is active sampler_bindings: ?*const GPUTextureSamplerBinding, // Additional fragment samplers to bind when this render state is active num_storage_textures: i32, // The number of storage textures to bind when this render state is active storage_textures: [*c]?*const GPUTexture, // Storage textures to bind when this render state is active num_storage_buffers: i32, // The number of storage buffers to bind when this render state is active storage_buffers: [*c]?*const GPUBuffer, // Storage buffers to bind when this render state is active props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed. }; pub const GPURenderState = opaque { pub inline fn setGPURenderStateFragmentUniforms(gpurenderstate: *GPURenderState, slot_index: u32, data: ?*const anyopaque, length: u32) bool { return @bitCast(c.SDL_SetGPURenderStateFragmentUniforms(@ptrCast(gpurenderstate), slot_index, data, length)); } pub inline fn destroyGPURenderState(gpurenderstate: *GPURenderState) void { return c.SDL_DestroyGPURenderState(@ptrCast(gpurenderstate)); } };