testing with samplegame

This commit is contained in:
peterino2 2025-06-11 00:04:17 -07:00
parent 3ac2d65347
commit a3c6563580
7 changed files with 35 additions and 42 deletions

View File

@ -433,12 +433,9 @@ pub fn generateApi(self: *@This(), programName: []const u8, moduleList: []const
mod.addImport(modName, self.nwdep.module(modName));
}
if (self.staticBuild) {
std.debug.print("what the fuck\n", .{});
const loadStatics = self.generateLoadStatics(programName, "content/_shaders") catch unreachable;
mod.addImport("staticShaderLoader", loadStatics);
// load each shader file recursively under content/_shaders
}
const loadStatics = self.generateLoadStatics(programName, "content/_shaders") catch unreachable;
mod.addImport("staticShaderLoader", loadStatics);
// load each shader file recursively under content/_shaders
return mod;
}

View File

@ -114,9 +114,13 @@ pub fn main() !void {
\\
\\ _ = core.createNameRegistry(allocator) catch return false;
\\ core.maybeInitPackerFs(allocator) catch return false;
\\
\\ const loader = @import("staticShaderLoader");
\\ loader.installStaticResources() catch return false;
\\
\\ if(core.BuildOption("static_build"))
\\ {
\\ core.engine_log("static build, using embedded shaders", .{});
\\ const loader = @import("staticShaderLoader");
\\ loader.installStaticResources() catch return false;
\\ }
\\
\\ if (!start_modules(spec, args, allocator)) return false;
\\ defer shutdown_modules(allocator);
@ -164,7 +168,7 @@ pub fn main() !void {
try content.append(0);
var ast = try std.zig.Ast.parse(allocator, @as([:0]const u8, @ptrCast(content.items[0 .. content.items.len - 1])), .zig);
std.debug.print("output=\n{s}", .{content.items[0 .. content.items.len - 1]});
// std.debug.print("output=\n{s}", .{content.items[0 .. content.items.len - 1]});
defer ast.deinit(allocator);
const out = try ast.render(allocator);

View File

@ -16,8 +16,8 @@ pub fn main() !void {
var content = std.ArrayList(u8).init(allocator);
var writer = content.writer();
const content_path = args[2];
std.debug.print("content path: {s}\n", .{content_path});
// const content_path = args[2];
// std.debug.print("content path: {s}\n", .{content_path});
// check the content directory and search for all _spv files
@ -35,14 +35,14 @@ pub fn main() !void {
var walker = dir.iterate();
while (try walker.next()) |shaderType| {
std.debug.print("Walk: {s}\n", .{shaderType.name});
// std.debug.print("Walk: {s}\n", .{shaderType.name});
if (shaderType.kind == .directory) {
var d2 = try dir.openDir(shaderType.name, .{ .iterate = true });
defer d2.close();
var w2 = d2.iterate();
while (try w2.next()) |shaderName| {
const shaderPath = try std.fmt.allocPrint(allocator, "_shaders/{s}/{s}", .{ shaderType.name, shaderName.name });
std.debug.print("mounted path: {s} => {s}\n", .{ shaderPath, shaderName.name });
// std.debug.print("mounted path: {s} => {s}\n", .{ shaderPath, shaderName.name });
try writer.print(
"{{ const embedded align(8) = @embedFile(\"{s}\").*;\n_ = try core.fs().installFileBytesMount(\"{s}\", @constCast(&embedded), true);}}\n",
.{ shaderName.name, shaderPath },
@ -67,7 +67,7 @@ pub fn main() !void {
var ast = try std.zig.Ast.parse(allocator, @as([:0]const u8, @ptrCast(content.items[0 .. content.items.len - 1])), .zig);
std.debug.print("output=\n{s}", .{content.items[0 .. content.items.len - 1]});
// std.debug.print("output=\n{s}", .{content.items[0 .. content.items.len - 1]});
defer ast.deinit(allocator);
const out = try ast.render(allocator);

View File

@ -26,8 +26,8 @@ pub fn start_module(spec: *core.SpecVariantMap, args: anytype, allocator: std.me
gSoundLoader.* = soundEngine.SoundLoader.init(gSoundEngine);
assets.getAssets().registerLoader(gSoundLoader) catch unreachable;
var name = core.MakeName("s_test");
gSoundEngine.loadSound(&name, "content/sounds/engineTick.wav", .{}) catch unreachable;
// var name = core.MakeName("s_test");
// gSoundEngine.loadSound(&name, "content/sounds/engineTick.wav", .{}) catch unreachable;
core.engine_logs("sound start_module");
}

View File

@ -191,6 +191,10 @@ pub const Parser = struct {
self.lineNumber += 1;
if (self.bytes[self.lineStart] == 0) {
return null;
}
return self.bytes[self.lineStart..self.lineEnd];
}

View File

@ -11,28 +11,22 @@ pub fn build(b: *std.Build) void {
.backlogRoot = "../",
});
const sampleGame = blbuild.addProgram(.{
const sampleGame = blbuild.program(.{
.name = "sampleGame",
.desc = "sdl3 project sample",
.root_source_file = b.path("sampleGame/main.zig"),
});
// new build api
//
// const game:BlProgram = blbuild.addProgram(...)
// game.addExtraModule(...)
// game.setModuleEnabled("physics", true);
// game.setModuleEnabled("audio", true);
// game.setModuleEnabled("audio", true);
//
//// commits changes and adds compile steps to the builder
// const sampleGame = game.addCompileSteps();
//
sampleGame.setModuleEnabled("imgui", true);
sampleGame.setModuleEnabled("audio", true);
sampleGame.setModuleEnabled("physics", true);
blbuild.addExtraModule(sampleGame, "gameExtras");
blbuild.addExtraModule(sampleGame, "videoplayer");
blbuild.addExtraModule(sampleGame, "doomplayer");
blbuild.addExtraModule(sampleGame, "bsp");
const mod = sampleGame.compileInstall();
blbuild.addExtraModule(mod, "gameExtras");
blbuild.addExtraModule(mod, "videoplayer");
blbuild.addExtraModule(mod, "doomplayer");
blbuild.addExtraModule(mod, "bsp");
// external reload modules
const sampleGameExtern = b.addSharedLibrary(.{

View File

@ -513,14 +513,8 @@ pub fn deinit(self: *@This()) void {
}
pub fn main() anyerror!void {
var spec = try backlog.createSpecVariant(.{
.name = "sampleGame",
.imgui = true,
.physics = true,
.audio = true,
}, std.heap.c_allocator);
_ = backlog.initAndRun(&NeonObjectTable, &spec);
var spec = try backlog.getSpec("sampleGame");
_ = backlog.startEngine(&NeonObjectTable, &spec);
// try backlog.initializeAndRunStandardProgram(@This(), .{
// .name = "sampleGame",
@ -539,7 +533,7 @@ const bsp = @import("bsp");
const FpCamera = extras.FpCamera;
const std = @import("std");
const backlog = @import("Backlog");
const backlog = @import("backlog");
const assets = backlog.assets;
const platform = backlog.platform;
const core = backlog.core;