allocator: std.mem.Allocator,

timer: std.time.Timer,
// fillPipeline: *sdl3.GpuGraphicsPipeline = undefined,
// linePipeline: *sdl3.GpuGraphicsPipeline = undefined,
// viewport: sdl3.GpuViewport = undefined,
// scissor: sdl3.Rect = undefined,

running: bool = true,

pub fn create(allocator: std.mem.Allocator) !*@This() {
    const self = try allocator.create(@This());
    self.* = .{
        .allocator = allocator,
        .timer = try std.time.Timer.start(),
    };

    return self;
}

pub fn startContext(self: *@This()) !void {
    try sdl3.init(.{
        .video = true,
        .gamepad = true,
    });

    const window = sdl3.c.SDL_CreateWindow("lmao your mom", 640, 480, 0);
    _ = window;

    _ = self;
}

pub fn loop(self: *@This()) !void {
    const dt = @as(f64, @floatFromInt(self.timer.lap())) / 1000 / 1000 / 1000;
    std.debug.print("loop started\n", .{});
    try self.startContext();
    while (self.running) {
        self.update(dt);
    }
}

fn update(self: *@This(), dt: f64) void {
    _ = dt;

    while (sdl3.pollEvent()) |event| {
        _ = event;
        // std.debug.print("{any} \n", .{event});
    }
    self.running = true;
}

pub fn destroy(self: *@This()) void {
    self.allocator.destroy(self);
}

pub fn main() !void {
    std.debug.print("creating context", .{});
    const app = try create(std.heap.c_allocator);
    try app.loop();
    defer app.destroy();
}

const sdl3 = @import("sdl3");
const std = @import("std");
