From 1730f1e2980bfa2819c541d9b8a3bc0301b8334e Mon Sep 17 00:00:00 2001 From: Lorenzo Torres Date: Thu, 27 Mar 2025 21:42:46 +0100 Subject: Made Renderer a separate module --- src/ecs/ecs.zig | 1 + src/ecs/entities.zig | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/ecs') diff --git a/src/ecs/ecs.zig b/src/ecs/ecs.zig index 278915b..9efc044 100644 --- a/src/ecs/ecs.zig +++ b/src/ecs/ecs.zig @@ -2,5 +2,6 @@ pub const components = @import("components.zig"); const entities = @import("entities.zig"); pub const Pool = entities.Pool; +pub const Resources = entities.Resources; pub const System = *const fn (*Pool) void; pub const SystemGroup = []const System; diff --git a/src/ecs/entities.zig b/src/ecs/entities.zig index 149c9ff..9337d6b 100644 --- a/src/ecs/entities.zig +++ b/src/ecs/entities.zig @@ -2,15 +2,21 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const components = @import("components.zig"); const sparse = @import("sparse.zig"); +const Renderer = @import("renderer"); pub const System = *const fn (*Pool) void; pub const SystemGroup = []const System; +pub const Resources = struct { + window: Renderer.Window, + renderer: Renderer, +}; + pub const Pool = struct { // Components position: sparse.SparseSet(components.Position), speed: sparse.SparseSet(components.Speed), - + resources: Resources, system_groups: std.ArrayList(SystemGroup), thread_pool: *std.Thread.Pool, wait_group: std.Thread.WaitGroup, @@ -20,11 +26,11 @@ pub const Pool = struct { component_flags: std.AutoHashMap(usize, usize), - pub fn init(allocator: Allocator) !@This() { + pub fn init(allocator: Allocator, resources: Resources) !@This() { var pool = @This(){ .position = sparse.SparseSet(components.Position).init(allocator), .speed = sparse.SparseSet(components.Speed).init(allocator), - + .resources = resources, .system_groups = std.ArrayList(SystemGroup).init(allocator), .thread_pool = try allocator.create(std.Thread.Pool), .wait_group = .{}, -- cgit v1.2.3