107 lines
3.1 KiB
Zig
107 lines
3.1 KiB
Zig
const std = @import("std");
|
|
pub const core = @import("core");
|
|
|
|
// meshes api
|
|
pub const meshes = @import("meshes/meshes.zig");
|
|
pub const JointNameEntry = meshes.JointNameEntry;
|
|
pub const MeshUpdate = meshes.MeshUpdate;
|
|
pub const MeshVertex = meshes.MeshVertex;
|
|
pub const IndexedMesh = meshes.IndexedMesh;
|
|
|
|
// components exports
|
|
pub const MeshComponent = @import("meshes/MeshComponent.zig");
|
|
pub const CameraComponent = @import("camera/CameraComponent.zig");
|
|
|
|
// asset loaders
|
|
pub const gltfLoader = @import("meshes/gltfLoader.zig");
|
|
|
|
// switch out based on backend implementation
|
|
pub const renderer = @import("sgpu/renderer.zig");
|
|
pub const context = renderer.context; // context getter func
|
|
pub const Renderer = renderer.Renderer;
|
|
|
|
pub const spng = @import("spng");
|
|
pub const png = @import("png.zig");
|
|
|
|
pub const MeshPool = renderer.MeshPool;
|
|
|
|
pub const getMesh = renderer.getMesh;
|
|
pub const getMeshByName = renderer.getMeshByName;
|
|
|
|
// camera API
|
|
pub const setActiveCamera = renderer.setActiveCamera;
|
|
|
|
pub const createRendererObject = renderer.createRendererObject;
|
|
pub const registerRendererObject = renderer.registerRendererObject;
|
|
|
|
pub const getTexture = renderer.getTexture;
|
|
pub const textureExists = renderer.textureExists;
|
|
pub const texture = @import("texture/texture.zig");
|
|
pub const Texture = texture.Texture;
|
|
|
|
pub const animationSystem = @import("animations/animationSystem.zig");
|
|
pub const animationResolver = @import("animations/animationResolver.zig");
|
|
const animationLoaders = @import("animations/loaders.zig");
|
|
|
|
pub const Animator = animationSystem.Animator;
|
|
|
|
pub const setSkyboxTexture = renderer.setSkyboxTexture;
|
|
|
|
pub const particles = @import("particles/particles.zig");
|
|
|
|
pub const ParticleSystem = particles.ParticleSystem;
|
|
pub const ParticleEmitter = particles.ParticleEmitter;
|
|
|
|
var rendAllocator: std.mem.Allocator = undefined;
|
|
pub fn getAllocator() std.mem.Allocator {
|
|
return rendAllocator;
|
|
}
|
|
|
|
// controls glfw and general windowing
|
|
// graphics depends on this one
|
|
pub const Module: core.ModuleDescription = .{
|
|
.name = "rend",
|
|
.enabledByDefault = true,
|
|
};
|
|
|
|
pub fn start_module(spec: *core.SpecVariantMap, args: anytype, allocator: std.mem.Allocator) !void {
|
|
_ = args;
|
|
_ = spec;
|
|
|
|
rendAllocator = allocator;
|
|
|
|
try renderer.createInstance();
|
|
try renderer.start();
|
|
|
|
_ = try context().createRendererEngineObject(animationSystem.AnimationSystem);
|
|
_ = try context().createRendererEngineObject(particles.ParticleSystem);
|
|
|
|
try animationLoaders.initLoaders();
|
|
try core.defineComponentList(ComponentList, allocator);
|
|
}
|
|
|
|
pub const ComponentList = struct {
|
|
pub const _MeshComponent = MeshComponent;
|
|
pub const _CameraComponent = CameraComponent;
|
|
pub const _Animator = Animator;
|
|
pub const _ParticleEmitter = ParticleEmitter;
|
|
};
|
|
|
|
pub fn setupFromModule() void {
|
|
if (core.getEngineObject(renderer.Renderer)) |r| {
|
|
rendAllocator = r.allocator;
|
|
}
|
|
|
|
core.ecs.patchComponentList(ComponentList);
|
|
}
|
|
|
|
pub fn shutdown_module(allocator: std.mem.Allocator) void {
|
|
core.undefineComponentList(ComponentList);
|
|
_ = allocator;
|
|
renderer.shutdown();
|
|
}
|
|
|
|
pub fn getMeshPool() *MeshPool {
|
|
return context().meshPool;
|
|
}
|