// --- # --- const std = @import("std"); const gtl = @import("gtl"); const sdl = @import("sdl"); const Self = @This(); // // // pub const Player = struct {}; /// ---------------------------------------------------- /// ---------------------------------------------------- pub const Texture = struct { id: u64 }; /// ---------------------------------------------------- /// ---------------------------------------------------- pub const GPUTexture = struct { path: []const u8, raw: ?*sdl.SDL_Texture, size: [2]i32 = .{ 0, 0 }, }; // // FIELDS // data: gtl.KeyedSlotMap(Texture, GPUTexture), /// ---------------------------------------------------- /// ---------------------------------------------------- pub fn init(alloc: std.mem.Allocator) Self { return .{ .data = .init(alloc), }; } /// ---------------------------------------------------- /// ---------------------------------------------------- pub fn deinit(self: *Self) void { for (self.data.items()) |entry| { if (entry.value.raw) |raw| { sdl.SDL_DestroyTexture(raw); } } self.data.deinit(); } /// ---------------------------------------------------- /// ---------------------------------------------------- pub fn load( self: *Self, comptime T: type, path: []const u8, ) !gtl.Handle(Texture) { // --- ID --- const id = gtl.TypeID(T); // --- # --- if (self.data.getHandle(.{ .id = id })) |h| { return h; } return try self.data.put(.{ .id = id }, .{ .path = path, .raw = null, }); }