Cleaned up rendering module

This commit is contained in:
Lorenzo Torres 2025-08-07 03:57:53 +02:00
parent 473c4aeffb
commit b1d092b6e3
10 changed files with 21 additions and 16 deletions

View file

@ -24,21 +24,19 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
const renderer = b.createModule(.{
.root_source_file = b.path("src/renderer/Renderer.zig"),
const rendering = b.createModule(.{
.root_source_file = b.path("src/rendering.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
renderer.addIncludePath(b.path("ext"));
renderer.addCSourceFile(.{ .file = b.path("ext/stb_image.c") });
//renderer.addImport("sideros", sideros);
renderer.addImport("math", math);
renderer.addImport("ecs", ecs);
// TODO(ernesto): ecs and renderer should be decoupled
ecs.addImport("renderer", renderer);
rendering.addIncludePath(b.path("ext"));
rendering.addCSourceFile(.{ .file = b.path("ext/stb_image.c") });
rendering.addImport("math", math);
rendering.addImport("ecs", ecs);
ecs.addImport("rendering", rendering);
compileAllShaders(b, renderer);
compileAllShaders(b, rendering);
const sideros = b.addLibrary(.{
.name = "sideros",
@ -53,7 +51,7 @@ pub fn build(b: *std.Build) void {
sideros.root_module.addImport("mods", mods);
sideros.root_module.addImport("ecs", ecs);
sideros.root_module.addImport("renderer", renderer);
sideros.root_module.addImport("rendering", rendering);
b.installArtifact(sideros);

View file

@ -2,8 +2,9 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const components = @import("components.zig");
const sparse = @import("sparse.zig");
const Renderer = @import("renderer");
const Camera = @import("renderer").Camera;
const rendering = @import("rendering");
const Renderer = rendering.Renderer;
const Camera = rendering.Camera;
const ecs = @import("ecs.zig");
const Input = ecs.Input;

4
src/rendering.zig Normal file
View file

@ -0,0 +1,4 @@
pub const Mesh = @import("rendering/Mesh.zig");
pub const vk = @import("rendering/vulkan.zig");
pub const Camera = @import("rendering/Camera.zig");
pub const Renderer = @import("rendering/Renderer.zig");

View file

@ -2,9 +2,9 @@ const math = @import("math");
const ecs = @import("ecs");
const std = @import("std");
const vk = @import("vulkan.zig");
pub const Mesh = @import("Mesh.zig");
const Mesh = @import("Mesh.zig");
const Texture = vk.Texture;
pub const Camera = @import("Camera.zig");
const Camera = @import("Camera.zig");
const Allocator = std.mem.Allocator;
const Renderer = @This();

View file

@ -1,7 +1,9 @@
pub const ecs = @import("ecs");
pub const Renderer = @import("renderer");
pub const rendering = @import("rendering");
pub const mods = @import("mods");
const Renderer = rendering.Renderer;
const api = @cImport({
@cInclude("sideros_api.h");
});