resource files working
This commit is contained in:
parent
e735c7ebdc
commit
1b8488b411
58
build.zig
58
build.zig
|
|
@ -20,6 +20,7 @@ nwdep: *std.Build.Dependency,
|
|||
apigen: *std.Build.Step.Compile,
|
||||
shaderEmbedGen: *std.Build.Step.Compile,
|
||||
loadDynamicsGen: *std.Build.Step.Compile,
|
||||
rcGen: *std.Build.Step.Compile,
|
||||
generatedApis: std.StringHashMapUnmanaged(*std.Build.Module) = .{},
|
||||
|
||||
const engineDepList = [_][]const u8{
|
||||
|
|
@ -82,6 +83,7 @@ pub fn init(b: *std.Build, opts: InitOptions) BuildSystem {
|
|||
.nwdep = nwdep,
|
||||
.apigen = nwdep.artifact("backlog-apigen"),
|
||||
.loadDynamicsGen = nwdep.artifact("backlog-generate-loadDynamics"),
|
||||
.rcGen = nwdep.artifact("backlog-generate-rc"),
|
||||
.shaderEmbedGen = nwdep.artifact("backlog-shaderEmbedGen"),
|
||||
};
|
||||
|
||||
|
|
@ -324,7 +326,7 @@ pub const DynamicModule = struct {
|
|||
|
||||
const b = self.buildSystem.b;
|
||||
const static = self.buildSystem.staticBuild;
|
||||
const shared = if (static)
|
||||
const lib = if (static)
|
||||
b.addStaticLibrary(.{
|
||||
.root_source_file = self.opts.root_source_file,
|
||||
.link_libc = true,
|
||||
|
|
@ -350,22 +352,22 @@ pub const DynamicModule = struct {
|
|||
}
|
||||
|
||||
for (self.extras.items) |extra| {
|
||||
self.buildSystem.addExtraModule(shared.root_module, extra.name);
|
||||
self.buildSystem.addExtraModule(lib.root_module, extra.name);
|
||||
}
|
||||
|
||||
shared.root_module.addImport("backlog", self.buildSystem.generateApi(self.name, modlist.items, null));
|
||||
shared.root_module.addOptions("BacklogOptions", self.buildSystem.options);
|
||||
lib.root_module.addImport("backlog", self.buildSystem.generateApi(self.name, modlist.items, null));
|
||||
lib.root_module.addOptions("BacklogOptions", self.buildSystem.options);
|
||||
|
||||
if (static) {
|
||||
// generateApi should create static callers for the main program
|
||||
} else {
|
||||
const installExtern = b.addInstallArtifact(shared, .{
|
||||
const installExtern = b.addInstallArtifact(lib, .{
|
||||
.dest_dir = .{ .override = .{ .custom = "modules" } },
|
||||
});
|
||||
b.getInstallStep().dependOn(&installExtern.step);
|
||||
}
|
||||
|
||||
return shared;
|
||||
return lib;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -382,6 +384,24 @@ pub const Program = struct {
|
|||
dynamicModules: std.ArrayListUnmanaged(*DynamicModule) = .{},
|
||||
buildSystem: *BuildSystem,
|
||||
|
||||
iconPath: ?std.Build.LazyPath = null,
|
||||
|
||||
pub fn setIconPath(self: *@This(), path: []const u8) void {
|
||||
if (self.iconPath != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// const b = self.buildSystem.b;
|
||||
//const fmt = b.fmt("content/{s}", .{path});
|
||||
//const p = b.path(fmt);
|
||||
|
||||
//const absolute = p.getPath(b);
|
||||
|
||||
self.iconPath = self.buildSystem.generateRc(self.opts.name, path) catch return;
|
||||
// std.debug.print("absolute path: {s}", .{absolute});
|
||||
//std.debug.print("\nabsolute path: {s}\n", .{absolute});
|
||||
}
|
||||
|
||||
pub fn setModuleEnabled(self: *@This(), module: []const u8, enable: bool) void {
|
||||
for (self.gameModules.items) |*m| {
|
||||
if (std.mem.eql(u8, m.name, module)) {
|
||||
|
|
@ -422,6 +442,15 @@ pub const Program = struct {
|
|||
|
||||
exe.addImport("backlog", self.buildSystem.generateApi(self.opts.name, modlist.items, self.dynamicModules.items));
|
||||
|
||||
if (self.buildSystem.target.result.os.tag == .windows) {
|
||||
if (self.iconPath) |ip| {
|
||||
exe.addWin32ResourceFile(.{
|
||||
.file = ip,
|
||||
.flags = &.{},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return exe;
|
||||
}
|
||||
};
|
||||
|
|
@ -481,6 +510,13 @@ pub fn build(b: *std.Build) void {
|
|||
.root_source_file = b.path("build/generateEmbeddedShaders.zig"),
|
||||
});
|
||||
|
||||
const generateRcExe = b.addExecutable(.{
|
||||
.name = "backlog-generate-rc",
|
||||
.target = b.graph.host,
|
||||
.optimize = .Debug,
|
||||
.root_source_file = b.path("build/generateRc.zig"),
|
||||
});
|
||||
|
||||
const generateLoadDynamicsExe = b.addExecutable(.{
|
||||
.name = "backlog-generate-loadDynamics",
|
||||
.target = b.graph.host,
|
||||
|
|
@ -491,6 +527,7 @@ pub fn build(b: *std.Build) void {
|
|||
b.installArtifact(generateLoadDynamicsExe);
|
||||
b.installArtifact(generateExe);
|
||||
b.installArtifact(generateShaders);
|
||||
b.installArtifact(generateRcExe);
|
||||
|
||||
{
|
||||
const loadDynamicsStub = b.addModule("loadDynamicsStub", .{
|
||||
|
|
@ -584,6 +621,15 @@ pub fn generateApi(self: *@This(), programName: []const u8, moduleList: []const
|
|||
return mod;
|
||||
}
|
||||
|
||||
pub fn generateRc(self: *@This(), programName: []const u8, iconPath: []const u8) !std.Build.LazyPath {
|
||||
const run = self.b.addRunArtifact(self.rcGen);
|
||||
const pfile = self.b.fmt("{s}.rc", .{programName});
|
||||
const output = run.addOutputFileArg(pfile);
|
||||
run.addArg(iconPath);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
pub fn generateLoadDynamics(self: *@This(), programName: []const u8, dynamics: []const *DynamicModule) !*std.Build.Module {
|
||||
const run = self.b.addRunArtifact(self.loadDynamicsGen);
|
||||
const pfile = self.b.fmt("{s}LoadDynamics.zig", .{programName});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
// Get output filename from build system
|
||||
const args = try std.process.argsAlloc(allocator);
|
||||
if (args.len < 3) @panic("Missing output filename");
|
||||
const out_path = args[1];
|
||||
|
||||
// Generate a startup module function that invokes
|
||||
// startup module for each zig function
|
||||
// and generates an api
|
||||
var content = std.ArrayList(u8).init(allocator);
|
||||
var writer = content.writer();
|
||||
const iconPath = args[2];
|
||||
|
||||
try writer.print("#include <windows.h>\r\n", .{});
|
||||
try writer.print("IDI_ICON1 ICON \"../../../content/", .{}); //{s}\"", .{iconPath});
|
||||
for (iconPath) |c| {
|
||||
if (c == '\\') {
|
||||
try writer.writeByte('/');
|
||||
} else {
|
||||
try writer.writeByte(c);
|
||||
}
|
||||
}
|
||||
try writer.writeByte('"');
|
||||
|
||||
// Write to specified output file
|
||||
// Open or create the file for writing (overwrites if it exists)
|
||||
const file = try std.fs.cwd().createFile(out_path, .{});
|
||||
defer file.close();
|
||||
|
||||
// Write the content to the file
|
||||
try file.writeAll(content.items);
|
||||
}
|
||||
|
|
@ -19,7 +19,33 @@ pub const std_options = std.Options{
|
|||
// std.debug.defaultPanic(error_return_trace, x, msg);
|
||||
// }
|
||||
|
||||
fn fileExists(path: []const u8) bool {
|
||||
std.fs.cwd().access(path, .{}) catch return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
if (!core.BuildOption("RootDeploymentOnly")) {
|
||||
// if we don't see a content/ folder or a
|
||||
// content.pak file in the current directory,
|
||||
// walk up the directory tree until we see one, then change dirs to that before doing anything else
|
||||
|
||||
var iterations: u32 = 0;
|
||||
var BUFFER: [8192]u8 = undefined;
|
||||
|
||||
while (iterations < 32) : (iterations += 1) {
|
||||
if (fileExists("content") or fileExists("content.pak")) {
|
||||
break;
|
||||
}
|
||||
|
||||
var dir = try std.fs.cwd().openDir("..", .{});
|
||||
defer dir.close();
|
||||
core.engine_log("content not found scanning dir {s}", .{try dir.realpath(".", &BUFFER)});
|
||||
try dir.setAsCwd();
|
||||
}
|
||||
core.engine_log("Working Dir set: {s}", .{try std.fs.cwd().realpath(".", &BUFFER)});
|
||||
}
|
||||
|
||||
panickers.attachSegfaultHandler();
|
||||
try realMain.main();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
// workaround forwarder
|
||||
|
||||
pub const core = @import("core").module;
|
||||
pub const rend = @import("rend").module;
|
||||
pub const imgui = @import("imgui").module;
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
pub const FpCamera = @import("FpCamera.zig");
|
||||
pub const inputDebugger = @import("inputDebugger.zig");
|
||||
pub const ObjectSpawner = @import("objectSpawner.zig");
|
||||
pub const RendererDebug = @import("RendererDebug.zig");
|
||||
pub const EngineTool = @import("EngineTool.zig");
|
||||
pub const FpCamera = @import("gameplay/FpCamera.zig");
|
||||
pub const pawns = @import("gameplay/pawns.zig");
|
||||
|
||||
pub const PhysicsObjectList = @import("PhysicsObjectList.zig");
|
||||
pub const inputDebugger = @import("debuggers/inputDebugger.zig");
|
||||
pub const ObjectSpawner = @import("debuggers/objectSpawner.zig");
|
||||
pub const RendererDebug = @import("debuggers/RendererDebug.zig");
|
||||
pub const EngineTool = @import("debuggers/EngineTool.zig");
|
||||
pub const PhysicsObjectList = @import("debuggers/PhysicsObjectList.zig");
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
// creates a
|
||||
|
|
@ -0,0 +1 @@
|
|||
// this is an implementation of
|
||||
|
|
@ -58,6 +58,15 @@ pub const Settings = struct {
|
|||
contentFolderExtraPaths: []const []const u8 = &[_][]const u8{}, // By default, this will mount the content/ folder on disk.
|
||||
};
|
||||
|
||||
pub const AnyWatchCallback = struct {
|
||||
func: *const fn ([]const u8, ?*anyopaque) void,
|
||||
ctx: ?*anyopaque = null,
|
||||
|
||||
pub inline fn call(self: *@This(), path: []const u8) void {
|
||||
self.func(path, self.ctx);
|
||||
}
|
||||
};
|
||||
|
||||
pub const WatchCallback = struct {
|
||||
func: *const fn ([]const u8, ?*anyopaque) void,
|
||||
ctx: ?*anyopaque = null,
|
||||
|
|
@ -82,6 +91,7 @@ pub const PackerFS = struct {
|
|||
|
||||
lock: std.Thread.Mutex = .{},
|
||||
|
||||
anyWatchCallbacks: std.ArrayListUnmanaged(AnyWatchCallback) = .{},
|
||||
fileWatchCallbacks: std.ArrayListUnmanaged(WatchCallback) = .{},
|
||||
|
||||
pub const PakMounting = struct {
|
||||
|
|
@ -147,6 +157,11 @@ pub const PackerFS = struct {
|
|||
try self.fileWatchCallbacks.append(self.allocator, x);
|
||||
}
|
||||
|
||||
// sets up a callback for if ANY file changes
|
||||
pub fn addAnyWatchCallback(self: *@This(), callback: *const fn (path: []const u8, ctx: ?*anyopaque) void, ctx: ?*anyopaque) !void {
|
||||
try self.anyWatchCallbacks.append(self.allocator, .{ .func = callback, .ctx = ctx });
|
||||
}
|
||||
|
||||
pub fn watchCallback(path: [*c]const u8, ctx: ?*anyopaque) callconv(.C) void {
|
||||
const self: *@This() = @ptrCast(@alignCast(ctx));
|
||||
// std.debug.print("WE GOT OURSELFS A FUCKIN CALLBAKC FOR A PATH MOTHERF- {s} {p} {d}\n", .{ path, ctx.?, self.pakMountings.items.len });
|
||||
|
|
@ -158,6 +173,10 @@ pub const PackerFS = struct {
|
|||
}
|
||||
// std.debug.print("registered callback: {s}\n", .{watch.path});
|
||||
}
|
||||
|
||||
for (self.anyWatchCallbacks.items) |*watch| {
|
||||
watch.call(std.mem.span(path));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn watchPath(self: *@This(), path: []const u8) void {
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
Saved/*
|
||||
.fontcache/*
|
||||
binaries/*
|
||||
content/bsp/autosave/*
|
||||
|
|
|
|||
|
|
@ -31,7 +31,14 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
_ = externGame.compileInstall();
|
||||
}
|
||||
_ = sampleGame.compileInstall();
|
||||
const sampleGameExe = sampleGame.compileInstall();
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
sampleGameExe.addWin32ResourceFile(.{
|
||||
.file = b.path("sampleGame/sampleGame.rc"),
|
||||
.flags = &.{},
|
||||
});
|
||||
}
|
||||
|
||||
// tools
|
||||
|
||||
|
|
@ -44,6 +51,7 @@ pub fn build(b: *std.Build) void {
|
|||
newProjectMaker.setModuleEnabled("imgui", true);
|
||||
newProjectMaker.setModuleEnabled("audio", false);
|
||||
newProjectMaker.setModuleEnabled("sys", true);
|
||||
newProjectMaker.setIconPath("icons/NewProject.ico");
|
||||
_ = newProjectMaker.compileInstall();
|
||||
|
||||
const toolbox = blbuild.program(.{
|
||||
|
|
@ -55,7 +63,15 @@ pub fn build(b: *std.Build) void {
|
|||
toolbox.setModuleEnabled("imgui", true);
|
||||
toolbox.setModuleEnabled("audio", false);
|
||||
toolbox.setModuleEnabled("sys", true);
|
||||
_ = toolbox.compileInstall();
|
||||
|
||||
const toolboxExe = toolbox.compileInstall();
|
||||
// Add Windows icon resource for toolbox
|
||||
if (target.result.os.tag == .windows) {
|
||||
toolboxExe.addWin32ResourceFile(.{
|
||||
.file = b.path("tools/toolbox.rc"),
|
||||
.flags = &.{},
|
||||
});
|
||||
}
|
||||
|
||||
blbuild.addDependencyInstalls(b, .ReleaseFast); //.ReleaseFast);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
|
@ -0,0 +1,105 @@
|
|||
[ENGINE ]: defining componentScene
|
||||
[ENGINE ]: Component container created scene.Scene @1f698af1300
|
||||
[ENGINE ]: creating lua metatable Scene
|
||||
[ENGINE ]: module started >>>> core <<<<
|
||||
[ENGINE ]: allocated size: 4034825 (3.848 MiB)
|
||||
[ENGINE ]: peak allocated size size: 4034953 (3.848 MiB) (72 peak allocations)
|
||||
[ENGINE ]: module started >>>> assets <<<<
|
||||
[ENGINE ]: platform settings windowing.PlatformParams{ .extent = math.Vector2Type(c_int,"Vector2c"[0..8]){ .x = 1600, .y = 900 }, .resizeable = true, .windowName = { 66, 97, 99, 107, 108, 111, 103, 32, 69, 110, 103, 105, 110, 101 }, .icon = { 116, 101, 120, 116, 117, 114, 101, 115, 47, 105, 99, 111, 110, 46, 112, 110, 103 }, .hasVideo = true }
|
||||
[ENGINE ]: module started >>>> platform <<<<
|
||||
[ENGINE ]: sgpu device created, using shader format: .spv
|
||||
[ENGINE ]: using renderer... scientist
|
||||
[ENGINE ]: creating shader meshes.vert => _shaders/spv/meshes.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 }
|
||||
[ENGINE ]: creating shader lit_mesh.frag => _shaders/spv/lit_mesh.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 4, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 }
|
||||
[GRAPHICS ]: swapchain format: gpu.GPUTextureFormat.textureformatB8g8r8a8Unorm
|
||||
[ENGINE ]: creating shader postProc.vert => _shaders/spv/postProc.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
|
||||
[ENGINE ]: creating shader postProc.frag => _shaders/spv/postProc.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 3, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
|
||||
[GRAPHICS ]: hdr texture format format: gpu.GPUTextureFormat.textureformatR16g16b16a16Float
|
||||
[GRAPHICS ]: mesh pool created 4000k vertices, 16000k indices
|
||||
[ENGINE ]: asset loader for asset type (Mesh) registered
|
||||
[ENGINE ]: Texture List Added
|
||||
[ENGINE ]: asset loader for asset type (Texture) registered
|
||||
[ENGINE ]: creating blocky sampler
|
||||
[ENGINE ]: loading asset t_default (Texture) [embedded:texture_sample.png]
|
||||
[ENGINE ]: loading texture t_default
|
||||
[ENGINE ]: creating mipmap level 9
|
||||
[ENGINE ]: loading asset m_default_cube (Mesh) [embedded:primitive_box.obj]
|
||||
[ENGINE ]: loading mesh asset embedded:primitive_box.obj [obj]
|
||||
[GRAPHICS ]: [embedded:primitive_box.obj] vertex count vertices=24 indices=36
|
||||
[ENGINE ]: [DebugDrawSystem] starting up...
|
||||
[ENGINE ]: loading asset m_debug_box (Mesh) [embedded:debug_box.obj]
|
||||
[ENGINE ]: loading mesh asset embedded:debug_box.obj [obj]
|
||||
[GRAPHICS ]: [embedded:debug_box.obj] vertex count vertices=24 indices=36
|
||||
[ENGINE ]: loading asset m_debug_line (Mesh) [embedded:debug_line.obj]
|
||||
[ENGINE ]: loading mesh asset embedded:debug_line.obj [obj]
|
||||
[GRAPHICS ]: [embedded:debug_line.obj] vertex count vertices=2 indices=3
|
||||
[ENGINE ]: loading asset m_debug_sphere (Mesh) [embedded:debug_sphere.obj]
|
||||
[ENGINE ]: loading mesh asset embedded:debug_sphere.obj [obj]
|
||||
[GRAPHICS ]: [embedded:debug_sphere.obj] vertex count vertices=240 indices=336
|
||||
[ENGINE ]: [DebugDrawSystem] registering to renderer...
|
||||
[ENGINE ]: creating shader debug.vert => _shaders/spv/debug.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 }
|
||||
[ENGINE ]: creating shader debug.frag => _shaders/spv/debug.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
|
||||
[ENGINE ]: creating shader meshes.vert => _shaders/spv/meshes.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 }
|
||||
[ENGINE ]: creating shader depthOnly.frag => _shaders/spv/depthOnly.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
|
||||
[ENGINE ]: loading asset m_skybox (Mesh) [embedded:skybox_mesh.obj]
|
||||
[ENGINE ]: loading mesh asset embedded:skybox_mesh.obj [obj]
|
||||
[GRAPHICS ]: [embedded:skybox_mesh.obj] vertex count vertices=24 indices=36
|
||||
[ENGINE ]: creating shader skybox.vert => _shaders/spv/skybox.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 }
|
||||
[ENGINE ]: creating shader skybox.frag => _shaders/spv/skybox.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 1, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 }
|
||||
[ENGINE ]: loading asset m_plane (Mesh) [embedded:plane.obj]
|
||||
[ENGINE ]: loading mesh asset embedded:plane.obj [obj]
|
||||
[GRAPHICS ]: [embedded:plane.obj] vertex count vertices=4 indices=6
|
||||
[ENGINE ]: loading asset m_screenPlane (Mesh) [embedded:screenPlane.obj]
|
||||
[ENGINE ]: loading mesh asset embedded:screenPlane.obj [obj]
|
||||
[GRAPHICS ]: [embedded:screenPlane.obj] vertex count vertices=4 indices=6
|
||||
[ENGINE ]: creating ssao pipeline
|
||||
[ENGINE ]: creating shader postProc.vert => _shaders/spv/postProc.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
|
||||
[ENGINE ]: creating shader ssao.frag => _shaders/spv/ssao.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 3, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 }
|
||||
[ENGINE ]: defining component_MeshComponent
|
||||
[ENGINE ]: Component container created meshes.MeshComponent @1f698af4080
|
||||
[ENGINE ]: creating lua metatable Mesh
|
||||
[ENGINE ]: defining component_CameraComponent
|
||||
[ENGINE ]: Component container created camera.CameraComponent @1f698ac1c00
|
||||
[ENGINE ]: creating lua metatable Camera
|
||||
[ENGINE ]: module started >>>> rend <<<<
|
||||
[GRAPHICS ]: imgui startup
|
||||
[ENGINE ]: module started >>>> imgui <<<<
|
||||
[ENGINE ]: creating Game context
|
||||
[ENGINE ]: calling gEngine.run
|
||||
[ENGINE ]: engine loop started
|
||||
[ENGINE ]: program ready
|
||||
[ENGINE ]: uploading mesh => m_default_cube
|
||||
[GRAPHICS ]: uploading 24 vertices and 36 indices
|
||||
[ENGINE ]: install mesh by name 16
|
||||
[ENGINE ]: uploading mesh => m_debug_box
|
||||
[GRAPHICS ]: uploading 24 vertices and 36 indices
|
||||
[ENGINE ]: install mesh by name 20
|
||||
[ENGINE ]: uploading mesh => m_debug_line
|
||||
[GRAPHICS ]: uploading 2 vertices and 3 indices
|
||||
[ENGINE ]: install mesh by name 21
|
||||
[ENGINE ]: uploading mesh => m_debug_sphere
|
||||
[GRAPHICS ]: uploading 240 vertices and 336 indices
|
||||
[ENGINE ]: install mesh by name 22
|
||||
[ENGINE ]: uploading mesh => m_skybox
|
||||
[GRAPHICS ]: uploading 24 vertices and 36 indices
|
||||
[ENGINE ]: install mesh by name 30
|
||||
[ENGINE ]: uploading mesh => m_plane
|
||||
[GRAPHICS ]: uploading 4 vertices and 6 indices
|
||||
[ENGINE ]: install mesh by name 37
|
||||
[ENGINE ]: uploading mesh => m_screenPlane
|
||||
[GRAPHICS ]: uploading 4 vertices and 6 indices
|
||||
[ENGINE ]: install mesh by name 38
|
||||
[ENGINE ]: Processing exit signals
|
||||
[ENGINE ]: checking everything is ready to exit
|
||||
[ENGINE ]: checking everything is ready to exit engineObject.InterfaceRef2(engineObject.EngineObjectVTable){ .ptr = anyopaque@1f698af1600, .vtable = engineObject.EngineObjectVTable{ .typeName = { 119, 105, 110, 100, 111, 119, 105, 110, 103, 46, 80, 108, 97, 116, 102, 111, 114, 109, 73, 110, 115, 116, 97, 110, 99, 101 }, .typeSize = 112, .typeAlign = 8, .singletonName = { 112, 108, 97, 116, 102, 111, 114, 109, 46, 73, 110, 115, 116, 97, 110, 99, 101 }, .init_func = fn (mem.Allocator) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!*anyopaque@7ff75e930a40, .tick_func = null, .engineDraw_func = null, .preTick_func = null, .deinit_func = fn (*anyopaque) void@7ff75e930ca0, .postInit_func = null, .processEvents = null, .exitSignal_func = fn (*anyopaque) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!void@7ff75e930b80, .readyToExit_func = fn (*anyopaque) bool@7ff75e930c00, .prepare_func = null, .fieldListHash = null, .fieldList = null, .slackSize = null } }
|
||||
[ENGINE ]: exiting
|
||||
[ENGINE ]: module shutting down >>>> imgui <<<<
|
||||
[ENGINE ]: module shutting down >>>> rend <<<<
|
||||
[ENGINE ]: undefining component meshes.MeshComponent
|
||||
[ENGINE ]: undefining component camera.CameraComponent
|
||||
[ENGINE ]: module shutting down >>>> platform <<<<
|
||||
[ENGINE ]: module shutting down >>>> assets <<<<
|
||||
[ENGINE ]: module shutting down >>>> core <<<<
|
||||
[ENGINE ]: allocated size: 3065691 (2.924 MiB)
|
||||
[ENGINE ]: peak allocated size size: 4989728 (4.759 MiB) (143 peak allocations)
|
||||
[ENGINE ]: undefining component scene.Scene
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
#include <windows.h>
|
||||
IDI_ICON1 ICON "../content/icons/icon.ico"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#include <windows.h>
|
||||
|
||||
IDI_ICON1 ICON "../content/icons/Toolbox.ico"
|
||||
|
|
@ -10,6 +10,8 @@ activeCommand: ?*sys.SubprocessTask = null,
|
|||
showInstructions: bool = false,
|
||||
dockingInitialized: bool = false,
|
||||
|
||||
animationStore: *AnimationStore = undefined,
|
||||
|
||||
const Task = union(enum(u8)) {
|
||||
subprocess: *sys.SubprocessTask,
|
||||
func: *const fn (*GameContext) void,
|
||||
|
|
@ -26,11 +28,12 @@ pub fn init(allocator: std.mem.Allocator) !*@This() {
|
|||
}
|
||||
|
||||
pub fn prepare(self: *@This()) !void {
|
||||
_ = self;
|
||||
core.engine_log("program ready", .{});
|
||||
if (core.getEngineObject(imgui.utils.TopBar)) |topbar| {
|
||||
topbar.menuOpen = true;
|
||||
}
|
||||
|
||||
self.animationStore = try AnimationStore.create(self.allocator);
|
||||
}
|
||||
|
||||
pub fn tick(self: *@This(), dt: f64) void {
|
||||
|
|
@ -251,6 +254,7 @@ fn displayInstructions(self: *@This()) void {
|
|||
}
|
||||
|
||||
pub fn deinit(self: *@This()) void {
|
||||
self.animationStore.destroy();
|
||||
self.allocator.destroy(self);
|
||||
}
|
||||
|
||||
|
|
@ -282,6 +286,8 @@ pub fn main() anyerror!void {
|
|||
_ = api.startEngine(&NeonObjectTable, &spec);
|
||||
}
|
||||
|
||||
const AnimationStore = @import("toolbox/animationStore.zig");
|
||||
|
||||
const builtin = @import("builtin");
|
||||
const std = @import("std");
|
||||
const api = @import("backlog");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,126 @@
|
|||
allocator: std.mem.Allocator,
|
||||
gltfs: std.StringHashMapUnmanaged(GltfData) = .{},
|
||||
stringArena: std.heap.ArenaAllocator,
|
||||
|
||||
filesToProcess: std.ArrayListUnmanaged(FileToProcess) = .{},
|
||||
|
||||
pub const FileToProcess = struct {
|
||||
path: []const u8,
|
||||
};
|
||||
|
||||
pub const GltfAnimationData = struct {
|
||||
name: []const u8,
|
||||
};
|
||||
|
||||
pub const GltfData = struct {
|
||||
filePath: []u8,
|
||||
animations: std.ArrayListUnmanaged(GltfAnimationData) = .{},
|
||||
};
|
||||
|
||||
pub fn create(allocator: std.mem.Allocator) !*@This() {
|
||||
const self = try allocator.create(@This());
|
||||
|
||||
self.* = .{
|
||||
.allocator = allocator,
|
||||
.stringArena = std.heap.ArenaAllocator.init(allocator),
|
||||
};
|
||||
|
||||
try self.setupCallbacks();
|
||||
try self.initialLoad();
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn setupCallbacks(self: *@This()) !void {
|
||||
core.fs().watchPath("content/");
|
||||
try core.fs().addAnyWatchCallback(fileChangedCallback, self);
|
||||
}
|
||||
|
||||
pub fn scanAll(self: *@This(), dir_path: []const u8) !void {
|
||||
var dir = try std.fs.cwd().openDir(dir_path, .{ .iterate = true });
|
||||
defer dir.close();
|
||||
|
||||
var it = dir.iterate();
|
||||
while (try it.next()) |entry| {
|
||||
const full_path = try std.fs.path.join(self.allocator, &.{ dir_path, entry.name });
|
||||
defer self.allocator.free(full_path);
|
||||
|
||||
if (entry.kind == .directory) {
|
||||
if (std.mem.eql(u8, entry.name, "_shaders")) {
|
||||
continue;
|
||||
}
|
||||
try self.scanAll(full_path); // Recursive call for subdirectories
|
||||
} else if (entry.kind == .file) {
|
||||
// core.engine_log("processing file: {s}", .{entry.name});
|
||||
try self.filesToProcess.append(self.allocator, .{ .path = entry.name });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn initialLoad(self: *@This()) !void {
|
||||
try self.scanAll("content/");
|
||||
}
|
||||
|
||||
pub fn fileChangedCallback(path: []const u8, ctx: ?*anyopaque) void {
|
||||
const self: *@This() = @ptrCast(@alignCast(ctx.?));
|
||||
// core.engine_log("file change seen {s}", .{path});
|
||||
//
|
||||
self.filesToProcess.append(self.allocator, .{ .path = path }) catch {};
|
||||
// self.updatePath(path) catch return;
|
||||
}
|
||||
|
||||
fn salloc(self: *@This()) std.mem.Allocator {
|
||||
return self.stringArena.allocator();
|
||||
}
|
||||
|
||||
pub fn updatePath(self: *@This(), path: []const u8) !void {
|
||||
core.engine_log("updating Path: {s}", .{path});
|
||||
if (std.mem.endsWith(u8, path, ".ozz")) {}
|
||||
|
||||
if (std.mem.endsWith(u8, path, ".gltf")) {
|
||||
// 1. check if there is a .cook file
|
||||
// if there is a .cook file
|
||||
// then dont load, no further actions needed
|
||||
|
||||
const pathstr = try std.fmt.allocPrint(self.salloc(), "{s}.cook", .{path[0 .. path.len - 5]});
|
||||
defer self.salloc().free(pathstr);
|
||||
|
||||
core.engine_log("checking path: {s}", pathstr);
|
||||
|
||||
if (!core.fs().fileExists(pathstr)) {
|
||||
// create a cook file under the pathstr, the file watcher should see it..
|
||||
core.engine_log("creating cooker {s}", .{pathstr});
|
||||
}
|
||||
|
||||
//var name = core.MakeName(pathstr);
|
||||
// if there is a cook file
|
||||
// var mapping = try core.fs().loadFile(path);
|
||||
// zgltf.init(self.allocator);
|
||||
// core.fs().unmap(mapping);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tick(self: *@This()) void {
|
||||
const start = core.getEngineTime();
|
||||
|
||||
while (self.filesToProcess.pop()) |pop| {
|
||||
const now = core.getEngineTime();
|
||||
if (now - start > 0.050) {
|
||||
break;
|
||||
}
|
||||
|
||||
self.updatePath(pop.path) catch {};
|
||||
}
|
||||
}
|
||||
|
||||
pub fn destroy(self: *@This()) void {
|
||||
self.allocator.destroy(self);
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const api = @import("backlog");
|
||||
const imgui = api.imgui;
|
||||
const ig = api.imgui.api;
|
||||
const core = api.core;
|
||||
const sys = api.sys;
|
||||
const zgltf = core.zgltf;
|
||||
|
|
@ -0,0 +1 @@
|
|||
zig build -Dstatic_build --watch --prominent-compile-errors -freference-trace -p binaries install
|
||||
Loading…
Reference in New Issue