2026-07-28 23:30:07 +01:00
|
|
|
//! ----------------------------------------------------
|
|
|
|
|
//! ----------------------------------------------------
|
|
|
|
|
|
|
|
|
|
const std = @import("std");
|
|
|
|
|
const gtl = @import("gtl");
|
|
|
|
|
const Material = @import("../../common/component/material.zig");
|
2026-07-29 01:15:31 +01:00
|
|
|
const Mesh = @import("../../cache/resource/mesh_cache.zig").MeshID;
|
2026-07-28 23:30:07 +01:00
|
|
|
const Handle = gtl.Handle;
|
|
|
|
|
const Self = @This();
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
const Camera = struct {};
|
|
|
|
|
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
pub const DrawCMD = union(enum) {
|
|
|
|
|
draw: struct {
|
2026-07-29 01:15:31 +01:00
|
|
|
mesh: Mesh,
|
2026-07-30 12:37:17 +02:00
|
|
|
material: Handle(Material),
|
2026-07-28 23:30:07 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
draw_indexed: struct {
|
2026-07-29 01:15:31 +01:00
|
|
|
mesh: Mesh,
|
2026-07-30 12:37:17 +02:00
|
|
|
material: Handle(Material),
|
2026-07-28 23:30:07 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
begin_pass: struct {
|
|
|
|
|
camera: Handle(Camera),
|
|
|
|
|
color: [4]f32 = .{ 0, 0, 0, 255 },
|
2026-07-29 15:56:52 +01:00
|
|
|
load_op: enum {
|
|
|
|
|
load,
|
|
|
|
|
clear,
|
|
|
|
|
} = .clear,
|
|
|
|
|
store_op: enum {
|
|
|
|
|
store,
|
|
|
|
|
discard,
|
|
|
|
|
} = .store,
|
2026-07-28 23:30:07 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
end_pass,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// FIELDS
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
commands: std.ArrayList(DrawCMD),
|
|
|
|
|
alloc: std.mem.Allocator,
|
|
|
|
|
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
pub fn init(alloc: std.mem.Allocator) Self {
|
|
|
|
|
return .{
|
|
|
|
|
.commands = .empty,
|
|
|
|
|
.alloc = alloc,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
pub fn deinit(self: *Self) void {
|
|
|
|
|
self.commands.deinit(self.alloc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
pub fn clear(self: *Self) void {
|
|
|
|
|
self.commands.clearRetainingCapacity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
/// ----------------------------------------------------
|
|
|
|
|
pub fn draw(
|
|
|
|
|
self: *Self,
|
|
|
|
|
cmd: DrawCMD,
|
|
|
|
|
) !void {
|
|
|
|
|
try self.commands.append(
|
|
|
|
|
self.alloc,
|
|
|
|
|
cmd,
|
|
|
|
|
);
|
|
|
|
|
}
|