forked from vv/efemra
1
0
Fork 0
efemra/src/rendering/textures.zig

68 lines
1.2 KiB
Zig

const vk = @import("vulkan");
const UUID = @import("../common/uuid.zig").UUID;
const RefTable = @import("../containers/table.zig").RefTable;
const Vec2i = @import("../math/vec.zig").Vec2i;
const TTable = RefTable(UUID, Texture);
var s_table: TTable = undefined;
pub fn init() void {
s_table = TTable.init();
}
pub fn update() void {}
pub fn deinit() void {}
pub fn getTable() *const TTable {
return &s_table;
}
pub const Texture = packed struct {
const Self = @This();
pub const Id = TTable.Id;
const PalRow = enum {
white,
brown,
light_blue,
green,
red,
orange,
gold,
peach,
purple,
magenta,
tan,
light_green,
yellow,
blue,
fire,
brights,
pub const count = @enumToInt(PalRow.brights);
};
size: Vec2i,
texels: [*]u8,
format: vk.Format,
slot: Id,
pub fn get(id: Id) ?*const Self {
return s_table.getPtr(id);
}
pub fn isCurrent(id: Id) bool {
return s_table.exists(id);
}
};
pub const DiskTexture = packed struct {
version: i32,
format: vk.Format,
name: []u8,
size: Vec2i,
};