so much work on hot reloading done

This commit is contained in:
Peter Li 2025-05-19 21:35:04 -07:00
parent 252a5271a1
commit 74228b388d
34 changed files with 16978 additions and 664 deletions

View File

@ -182,6 +182,10 @@ pub fn addExtraModule(self: *BuildSystem, mod: *std.Build.Module, moduleName: []
mod.addImport(moduleName, dep.module(moduleName)); mod.addImport(moduleName, dep.module(moduleName));
} }
pub fn addSDL3Install(self: *BuildSystem, b: *std.Build, optimize: std.builtin.OptimizeMode) void {
b.installArtifact(b.dependency("sdl3_lib", .{ .target = self.target, .optimize = optimize }).artifact("SDL3"));
}
// ========= standalone build instance ======= // ========= standalone build instance =======
// maybe it should be an engine launcher or something.. // maybe it should be an engine launcher or something..
pub fn build(b: *std.Build) void { pub fn build(b: *std.Build) void {
@ -194,20 +198,49 @@ pub fn build(b: *std.Build) void {
}); });
_ = spirvDep; _ = spirvDep;
const mod = b.addModule("Backlog", .{ {
.target = target, const mod = b.addModule("Backlog", .{
.optimize = optimize, .target = target,
.root_source_file = b.path("engine/backlog.zig"), .optimize = optimize,
}); .root_source_file = b.path("engine/backlog.zig"),
});
for (engineDepList) |depName| { for (engineDepList) |depName| {
const dep = b.dependency( const dep = b.dependency(
depName, depName,
.{ .{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}, },
); );
mod.addImport(depName, dep.module(depName)); mod.addImport(depName, dep.module(depName));
}
// link in large platform support functions
{
const dep = b.dependency("sdl3", .{ .target = target, .optimize = optimize });
const lib = dep.module("sdl3_lib");
mod.addImport("sdl3_fwd", lib);
}
}
{
const mod = b.addModule("BacklogExtern", .{
.target = target,
.optimize = optimize,
.root_source_file = b.path("engine/backlogExtern.zig"),
});
for (engineDepList) |depName| {
const dep = b.dependency(
depName,
.{
.target = target,
.optimize = optimize,
},
);
mod.addImport(depName, dep.module(depName));
}
} }
} }

View File

@ -13,6 +13,8 @@
.rend = .{.path = "engine/rend" }, .rend = .{.path = "engine/rend" },
.SpirvReflect = .{ .path = "lib/spirv-reflect-zig" }, .SpirvReflect = .{ .path = "lib/spirv-reflect-zig" },
.ozz = .{ .path = "lib/ozz" }, .ozz = .{ .path = "lib/ozz" },
.sdl3 = .{ .path = "lib/sdl3" },
.sdl3_lib = .{ .path = "lib/sdl3/SDL" },
}, },
.paths = .{ .paths = .{
"", "",

View File

@ -26,3 +26,5 @@ pub fn setupFromModule() void {
pub fn shutdown_module(allocator: std.mem.Allocator) void { pub fn shutdown_module(allocator: std.mem.Allocator) void {
_ = allocator; _ = allocator;
} }
pub const utils = @import("utils/utils.zig");

View File

@ -77,6 +77,8 @@ pub const Impl = struct {
pub fn preTick(self: *@This(), dt: f64) core.EngineDataEventError!void { pub fn preTick(self: *@This(), dt: f64) core.EngineDataEventError!void {
c.Imgui_SDL3_NewFrame(); c.Imgui_SDL3_NewFrame();
c.igNewFrame(); c.igNewFrame();
_ = ig.dockSpaceOverViewport(ig.getMainViewport(), .{ .passthru_central_node = true }, null);
_ = self; _ = self;
_ = dt; _ = dt;
} }

View File

@ -0,0 +1,55 @@
pub fn structDebugWindow(ptr: anytype) void {
const T = @typeInfo(@TypeOf(ptr)).pointer.child;
if (ig.begin("struct debugger: " ++ @typeName(T), null, .{})) {
ig.textf("{s} @ 0x{x}", .{ @typeName(T), @as(u64, @intFromPtr(ptr)) });
displayStruct(ptr, 0, 3);
}
ig.end();
}
var formatBuf: [128]u8 = undefined;
pub inline fn displayStruct(s: anytype, comptime depth: u32, comptime maxDepth: u32) void {
const TypeInfo = @typeInfo(@TypeOf(s.*)).@"struct";
const prefix = " " ** depth;
inline for (TypeInfo.fields) |field| {
const fieldTypeInfo = @typeInfo(field.type);
switch (fieldTypeInfo) {
.@"struct" => {
// todo add a struct display function
ig.textf(prefix ++ "{s}({s})[{d}]: size: {d} offset: {d}", .{
field.name,
@typeName(field.type),
depth,
@sizeOf(field.type),
@offsetOf(@TypeOf(s.*), field.name),
});
if (depth < maxDepth) {
displayStruct(&@field(s, field.name), depth + 1, maxDepth);
}
},
.pointer => {},
.float => {},
//.bool => {
//const checkboxtext = std.fmt.bufPrintZ(&formatBuf, "{s}", .{field.name}) catch "name too long";
// _ = ig.checkbox(checkboxtext, &@field(s, field.name));
//},
else => {
ig.textf(prefix ++ "UNIMPLEMENTED TYPE: {s} {s}: size: {d} offset: {d}", .{
@typeName(field.type),
field.name,
@sizeOf(field.type),
@offsetOf(@TypeOf(s.*), field.name),
});
},
}
}
}
const ig = @import("../imgui.zig").api;
const std = @import("std");

View File

@ -0,0 +1 @@
pub const structDebugWindow = @import("structDebugger.zig").structDebugWindow;

View File

@ -18,6 +18,10 @@ pub fn context() *windowing.PlatformInstance {
return gPlatformInstance; return gPlatformInstance;
} }
pub fn setupFromModule() void {
gPlatformInstance = core.getEngineObject(windowing.PlatformInstance).?;
}
pub fn getCursorPosition() core.Vector2f { pub fn getCursorPosition() core.Vector2f {
return gPlatformInstance.getCursorPosition(); return gPlatformInstance.getCursorPosition();
} }
@ -41,14 +45,17 @@ pub fn setImguiVisible(visible: bool) void {
pub fn start_module(spec: *core.SpecVariantMap, args: anytype, allocator: std.mem.Allocator) !void { pub fn start_module(spec: *core.SpecVariantMap, args: anytype, allocator: std.mem.Allocator) !void {
_ = args; _ = args;
_ = spec; _ = spec;
_ = allocator;
if (core.isUtility()) { if (core.isUtility()) {
return; return;
} }
const parameters = windowing.PlatformParams.init(); const parameters = windowing.PlatformParams.init();
gPlatformInstance = try allocator.create(windowing.PlatformInstance); gPlatformInstance = try core.createObject(windowing.PlatformInstance, .{}); //try allocator.create(windowing.PlatformInstance);
gPlatformInstance.* = try windowing.PlatformInstance.init(allocator, parameters); try gPlatformInstance.setParams(parameters);
// gPlatformInstance.* = try windowing.PlatformInstance.init(allocator, parameters);
try gPlatformInstance.setupWindow(); try gPlatformInstance.setupWindow();
@ -63,8 +70,5 @@ pub fn shutdown_module(allocator: std.mem.Allocator) void {
if (core.isUtility()) { if (core.isUtility()) {
return; return;
} }
_ = allocator;
gPlatformInstance.deinit();
allocator.destroy(gPlatformInstance);
} }

View File

@ -65,12 +65,6 @@ pub const PlatformParams = struct {
} }
}; };
pub var gPlatformSettings: struct {
pollLockoutTime: ?f32 = null,
decoratedWindow: bool = true,
transparentFrameBuffer: bool = false,
} = .{};
// For windows and linux computers this is a glfw instance // For windows and linux computers this is a glfw instance
pub const PlatformInstance = struct { pub const PlatformInstance = struct {
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
@ -81,11 +75,11 @@ pub const PlatformInstance = struct {
window: *sdl3.Window = undefined, window: *sdl3.Window = undefined,
windowExtent: core.Vector2c, windowExtent: core.Vector2c = undefined,
extent: core.Vector2f, extent: core.Vector2f = undefined,
windowName: [:0]u8, windowName: [:0]u8 = undefined,
iconPath: [:0]u8, iconPath: [:0]u8 = undefined,
enableImguiEvents: bool = true, enableImguiEvents: bool = true,
imguiVisible: bool = true, imguiVisible: bool = true,
@ -96,6 +90,8 @@ pub const PlatformInstance = struct {
cursorPos: core.Vector2f = .{}, cursorPos: core.Vector2f = .{},
pub var NeonObjectTable = core.EngineObjectVTable.from(@This(), "platform.Instance");
pub fn deinit(self: *@This()) void { pub fn deinit(self: *@This()) void {
self.allocator.free(self.windowName); self.allocator.free(self.windowName);
self.allocator.free(self.iconPath); self.allocator.free(self.iconPath);
@ -103,7 +99,7 @@ pub const PlatformInstance = struct {
// shutdown // shutdown
} }
pub fn onExitSignal(self: *@This()) void { pub fn onExitSignal(self: *@This()) !void {
sdl3.c.SDL_DestroyWindow(self.window); sdl3.c.SDL_DestroyWindow(self.window);
self.windowDestroyed = true; self.windowDestroyed = true;
} }
@ -114,20 +110,28 @@ pub const PlatformInstance = struct {
pub fn init( pub fn init(
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
params: PlatformParams, ) !*@This() {
) !@This() { const self = try allocator.create(@This());
const self: @This() = .{ self.* = .{
.allocator = allocator, .allocator = allocator,
.windowName = try allocator.dupeZ(u8, params.windowName), //.windowName = try allocator.dupeZ(u8, params.windowName),
.iconPath = try allocator.dupeZ(u8, params.icon), //.iconPath = try allocator.dupeZ(u8, params.icon),
.windowExtent = params.extent, //.windowExtent = params.extent,
.extent = .{ .x = @floatFromInt(params.extent.x), .y = @floatFromInt(params.extent.y) }, //.extent = .{ .x = @floatFromInt(params.extent.x), .y = @floatFromInt(params.extent.y) },
.hasVideo = params.hasVideo, //.hasVideo = params.hasVideo,
}; };
return self; return self;
} }
pub fn setParams(self: *@This(), params: PlatformParams) !void {
self.windowName = try self.allocator.dupeZ(u8, params.windowName);
self.iconPath = try self.allocator.dupeZ(u8, params.icon);
self.windowExtent = params.extent;
self.extent = .{ .x = @floatFromInt(params.extent.x), .y = @floatFromInt(params.extent.y) };
self.hasVideo = params.hasVideo;
}
pub fn setMouseRelativeMode(self: *@This(), relativeMode: bool) void { pub fn setMouseRelativeMode(self: *@This(), relativeMode: bool) void {
// _ = sdl3.c.SDL_SetHint(sdl3.c.SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, "1"); // _ = sdl3.c.SDL_SetHint(sdl3.c.SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, "1");
_ = sdl3.c.SDL_SetWindowRelativeMouseMode(self.window, relativeMode); _ = sdl3.c.SDL_SetWindowRelativeMouseMode(self.window, relativeMode);
@ -150,7 +154,7 @@ pub const PlatformInstance = struct {
} }
pub fn registerFuncs(self: *@This()) !void { pub fn registerFuncs(self: *@This()) !void {
core.setupEnginePlatform(self, enginePoll, processEvents); core.setupEnginePlatform(self, enginePoll, procEvents);
} }
// runs pinned on io thread. // runs pinned on io thread.
@ -170,7 +174,7 @@ pub const PlatformInstance = struct {
sdl3.c.SDL_WarpMouseInWindow(self.window, pos.x, pos.y); sdl3.c.SDL_WarpMouseInWindow(self.window, pos.x, pos.y);
} }
pub fn processEvents(ptr: *anyopaque, frameNumber: u64) core.EngineDataEventError!void { pub fn procEvents(ptr: *anyopaque, frameNumber: u64) core.EngineDataEventError!void {
_ = frameNumber; _ = frameNumber;
const self: *@This() = @ptrCast(@alignCast(ptr)); const self: *@This() = @ptrCast(@alignCast(ptr));

View File

@ -132,7 +132,7 @@ float4 main(float2 UV : TEXCOORD0) : SV_Target0
// c = SsaoTexture.Sample(Sampler2, uv).x; // c = SsaoTexture.Sample(Sampler2, uv).x;
// float4 ssao = SsaoTexture.Sample(Sampler2, uv); // float4 ssao = SsaoTexture.Sample(Sampler2, uv);
float ssao = blurSSAO(uv); float3 ssao = blurSSAO(uv);
c = c * ssao; c = c * ssao;
//float4 x = SsaoTexture.Sample(Sampler2, uv); //float4 x = SsaoTexture.Sample(Sampler2, uv);

View File

@ -1,7 +1,6 @@
pub const MeshPool = struct { pub const MeshPool = struct {
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
meshMap: std.AutoHashMapUnmanaged(u32, rend.IndexedMesh) = .{},
invalidations: std.AutoHashMapUnmanaged(u32, rend.IndexedMesh) = .{}, invalidations: std.AutoHashMapUnmanaged(u32, rend.IndexedMesh) = .{},
indexSpans: core.MergedSpans, indexSpans: core.MergedSpans,

View File

@ -66,7 +66,7 @@ pub const TBMap = struct {
// core.engine_log("adding vertex {any}", .{vert}); // core.engine_log("adding vertex {any}", .{vert});
const position = const position =
core.Vectorf{ core.Vectorf{
.x = @floatCast(vert.data[0]), .x = @floatCast(-vert.data[0]),
.y = @floatCast(vert.data[1]), .y = @floatCast(vert.data[1]),
.z = @floatCast(vert.data[2]), .z = @floatCast(vert.data[2]),
}; };
@ -184,7 +184,7 @@ pub const MeshBuilder = struct {
var normal = var normal =
core.Vectorf{ core.Vectorf{
.x = @floatCast(n.data[0]), .x = @floatCast(-n.data[0]),
.y = @floatCast(n.data[1]), .y = @floatCast(n.data[1]),
.z = @floatCast(n.data[2]), .z = @floatCast(n.data[2]),
}; };
@ -200,7 +200,7 @@ pub const MeshBuilder = struct {
const position = const position =
core.Vectorf{ core.Vectorf{
.x = @floatCast(vert.data[0]), .x = @floatCast(-vert.data[0]),
.y = @floatCast(vert.data[1]), .y = @floatCast(vert.data[1]),
.z = @floatCast(vert.data[2]), .z = @floatCast(vert.data[2]),
}; };

View File

@ -11,7 +11,7 @@ pub const revision = formatted_version ++ " (" ++ vendor_info ++ ")";
pub fn build(b: *std.Build) void { pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const preferred_linkage = b.option( var preferred_linkage: std.builtin.LinkMode = b.option(
std.builtin.LinkMode, std.builtin.LinkMode,
"preferred_linkage", "preferred_linkage",
"Prefer building statically or dynamically linked libraries (default: static)", "Prefer building statically or dynamically linked libraries (default: static)",
@ -20,6 +20,8 @@ pub fn build(b: *std.Build) void {
"preferred_link_mode", "preferred_link_mode",
"Deprecated; use 'preferred_linkage' instead", "Deprecated; use 'preferred_linkage' instead",
) orelse .static; ) orelse .static;
preferred_linkage = .dynamic;
const strip = b.option( const strip = b.option(
bool, bool,
"strip", "strip",
@ -544,7 +546,7 @@ pub fn build(b: *std.Build) void {
.pic = pic, .pic = pic,
}); });
const sdl_lib = b.addLibrary(.{ const sdl_lib = b.addLibrary(.{
.linkage = if (emscripten) .static else preferred_linkage, .linkage = .dynamic, //if (emscripten) .static else preferred_linkage,
.name = "SDL3", .name = "SDL3",
.root_module = sdl_mod, .root_module = sdl_mod,
.version = .{ .version = .{

File diff suppressed because it is too large Load Diff

52
lib/sdl3/apigen.py vendored Normal file
View File

@ -0,0 +1,52 @@
import os
import time
import json
import subprocess
class HeaderParser:
def __init__(self, headerList, target, headerName):
self.headerList = headerList
self.path = target
self.headerName = headerName
self.outputPrefix = "asts/" + headerName
self.astJsonFile = os.path.join(orig_dir, self.headerName + ".ast.json")
with open(self.astJsonFile) as f:
self.jsonRepr = json.load(f)
orig_dir = os.path.abspath(os.path.dirname(__file__))
inputList = []
def parseAll(sdl3IncludePath, headerList):
parsedList = []
for f in headerList:
if f.endswith(".h"):
headerName = f.split(".")[0]
if "_" in headerName:
headerName = headerName.split('_')[1]
print(headerName)
parsedList.append(os.path.join(sdl3IncludePath, f))
parsePath = os.path.join(sdl3IncludePath, 'SDL_gpu.h')
# os.system(f"cheader2json convert {f} --prefix={self.headerName}")
def parse():
global inputList
sdl3IncludePath = os.path.join(orig_dir, 'SDL/include/SDL3')
discoveredFiles = os.listdir(os.path.join(orig_dir, 'SDL/include/SDL3'))
parsedList = []
parseAll(sdl3IncludePath, discoveredFiles)
sdlHeaderList = []
for file in discoveredFiles:
sdlHeaderList.append(os.path.join(sdl3IncludePath, file))
parsed = HeaderParser(sdlHeaderList, os.path.join(sdl3IncludePath, 'SDL_gpu.h'), "gpu")
print("parsing list: ", inputList)
if __name__ == "__main__":
while True:
parse()

9
lib/sdl3/build.zig vendored
View File

@ -46,6 +46,13 @@ pub fn build(b: *std.Build) void {
}); });
const sdl3_lib = sdl_dep.artifact("SDL3"); const sdl3_lib = sdl_dep.artifact("SDL3");
const sdl3_fwd = b.addModule("sdl3_lib", .{
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/sdl3_lib_fwd.zig"),
});
sdl3_fwd.linkLibrary(sdl3_lib);
const mod = b.addModule("sdl3", .{ const mod = b.addModule("sdl3", .{
.target = target, .target = target,
@ -60,7 +67,7 @@ pub fn build(b: *std.Build) void {
mod.addImport("shaderTypes", shaderTypes.module("shaderTypes")); mod.addImport("shaderTypes", shaderTypes.module("shaderTypes"));
mod.addIncludePath(b.path("SDL/include")); mod.addIncludePath(b.path("SDL/include"));
mod.linkLibrary(sdl3_lib); // mod.linkLibrary(sdl3_lib);
const test_step = b.step("test", "run unit tests for sdl3"); const test_step = b.step("test", "run unit tests for sdl3");
const tests = b.addExecutable(.{ const tests = b.addExecutable(.{

0
lib/sdl3/clangParserLog.log vendored Normal file
View File

8033
lib/sdl3/gpu.ast.json vendored Normal file

File diff suppressed because it is too large Load Diff

3
lib/sdl3/gpu.types.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"functions": {}
}

0
lib/sdl3/src/SDLVTable.zig vendored Normal file
View File

View File

@ -32,7 +32,7 @@ origDir = os.path.abspath(os.path.dirname(__file__))
os.chdir(origDir) os.chdir(origDir)
infile = "../../SDL/include/SDL3/SDL_gpu.h" infile = "../../SDL/include/SDL3/SDL_gpu.h"
ofile = os.path.abspath(os.path.join(origDir, '../gpu.zig')) ofile = os.path.abspath(os.path.join(origDir, '../gpu2.zig'))
SDL_files = [ SDL_files = [
'SDL_gpu.h', 'SDL_gpu.h',

View File

@ -60,6 +60,9 @@ pub fn showCursor() void {
_ = c.SDL_ShowCursor(); _ = c.SDL_ShowCursor();
} }
pub const SDLVTable = @import("SDLVTable.zig");
const std = @import("std");
pub const gpu = @import("gpu.zig"); pub const gpu = @import("gpu.zig");
pub const Scancode = @import("scancode.zig").Scancode; pub const Scancode = @import("scancode.zig").Scancode;
pub const shaderTypes = @import("shaderTypes"); pub const shaderTypes = @import("shaderTypes");

0
lib/sdl3/src/sdl3_lib_fwd.zig vendored Normal file
View File

View File

@ -36,4 +36,6 @@ pub fn build(b: *std.Build) void {
.dest_dir = .{ .override = .{ .custom = "modules" } }, .dest_dir = .{ .override = .{ .custom = "modules" } },
}); });
b.getInstallStep().dependOn(&installExtern.step); b.getInstallStep().dependOn(&installExtern.step);
blbuild.addSDL3Install(b, .ReleaseFast); //.ReleaseFast);
} }

View File

@ -13,7 +13,10 @@
// engine libraries // engine libraries
.Backlog = .{ .path = "../" }, .Backlog = .{ .path = "../" },
.sdl3_lib = .{ .path = "../lib/sdl3/SDL" },
.SpirvReflect = .{ .path = "../lib/spirv-reflect-zig" }, .SpirvReflect = .{ .path = "../lib/spirv-reflect-zig" },
.gameExtras = .{.path = "../extras/gameExtras"}, .gameExtras = .{.path = "../extras/gameExtras"},
.videoplayer = .{.path = "../extras/videoplayer"}, .videoplayer = .{.path = "../extras/videoplayer"},
.doomplayer = .{.path = "../extras/doomplayer"}, .doomplayer = .{.path = "../extras/doomplayer"},

View File

@ -52,8 +52,8 @@ fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> ColorTexture
continue; continue;
} }
} }
float3 _143 = ((powr((_60 * (float3(1.0) + (_60 * float3(0.00999999977648258209228515625)))) / (float3(1.0) + _60), float3(0.4545454680919647216796875)) + (_74 * 0.0500000007450580596923828125)) * 1.0) * _109.x; float3 _142 = ((powr((_60 * (float3(1.0) + (_60 * float3(0.00999999977648258209228515625)))) / (float3(1.0) + _60), float3(0.4545454680919647216796875)) + (_74 * 0.0500000007450580596923828125)) * 1.0) * _109;
out.out_var_SV_Target0 = float4(((_143.x * (1.0 + (9.9999999747524270787835121154785e-07 * EmissiveTexture.sample(Sampler1, _51).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * ColorTexture.sample(Sampler0, _51).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * SsaoTexture.sample(Sampler2, _51).x)), _143.yz, 1.0); out.out_var_SV_Target0 = float4(((_142.x * (1.0 + (9.9999999747524270787835121154785e-07 * EmissiveTexture.sample(Sampler1, _51).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * ColorTexture.sample(Sampler0, _51).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * SsaoTexture.sample(Sampler2, _51).x)), _142.yz, 1.0);
return out; return out;
} }

View File

@ -8,7 +8,7 @@ struct type_Uniforms
float brightnessFactor; float brightnessFactor;
}; };
constant float4 _29 = {}; constant float4 _28 = {};
struct main0_out struct main0_out
{ {
@ -24,11 +24,9 @@ struct main0_in
fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], texturecube<float> SkyboxTexture [[texture(0)]], sampler SkyboxSampler [[sampler(0)]]) fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], texturecube<float> SkyboxTexture [[texture(0)]], sampler SkyboxSampler [[sampler(0)]])
{ {
main0_out out = {}; main0_out out = {};
float4 _39 = SkyboxTexture.sample(SkyboxSampler, in.in_var_TEXCOORD0) * Uniforms.brightnessFactor; float4 _38 = SkyboxTexture.sample(SkyboxSampler, in.in_var_TEXCOORD0) * Uniforms.brightnessFactor;
float4 _44 = _39; out.out_var_SV_Target0 = _38;
_44.z = 0.0; out.out_var_SV_Target1 = select(_28, _38, bool4(length(_38) > 1.0));
out.out_var_SV_Target0 = _44;
out.out_var_SV_Target1 = select(_29, _39, bool4(length(_39) > 1.0));
return out; return out;
} }

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,8 @@ pub export fn startup(p_allocator: *anyopaque, p_a: ?*anyopaque) bool {
const allocator = core.modulePreamble(p_allocator, p_a) catch return false; const allocator = core.modulePreamble(p_allocator, p_a) catch return false;
_ = allocator; _ = allocator;
imgui.setupFromModule(); imgui.setupFromModule();
platform.setupFromModule();
// TODO backlog.setupFromModule
start_module(core.startup_getArgs(p_a.?)) catch return false; start_module(core.startup_getArgs(p_a.?)) catch return false;
@ -51,24 +53,43 @@ pub const ExternGameObject = struct {
} }
pub fn tick(self: *@This(), dt: f64) void { pub fn tick(self: *@This(), dt: f64) void {
_ = self;
_ = dt; _ = dt;
_ = self;
const rctx = rend.context();
imgui.utils.structDebugWindow(rctx);
if (ig.begin("external game object", null, .{})) { if (ig.begin("external game object", null, .{})) {
ig.textf("sup", .{}); ig.textf("sup", .{});
ig.textf("hello !", .{});
ig.textf("sup", .{}); _ = ig.sliderFloat("skybox strength", &rctx.skyboxSystem.brightnessFactor, 0, 10, null, .{});
ig.textf("hello !", .{});
ig.textf("sup", .{});
ig.textf("hello !", .{});
ig.textf("sup", .{});
ig.textf("hello !", .{});
ig.textf("sup", .{});
ig.textf("hello !", .{});
ig.textf("sup", .{});
ig.textf("hello !", .{});
_ = ig.sliderFloat("skybox red", &rend.context().skyboxSystem.brightnessFactor, 0, 200, null, .{}); if (rctx.activeCamera) |camera| {
const forwardVector = camera.forward();
ig.textf("forward vector x:{d} y:{d} z:{d}", .{ forwardVector.x, forwardVector.y, forwardVector.z });
}
ig.textf("window at 0x{x}", .{@intFromPtr(backlog.platform.context().window)});
if (ig.smallButton("click to show sdl messagebox")) {
//_ = backlog.platform.windowing.sdl3.c.SDL_ShowSimpleMessageBox(0, "lmao", "you lmaoed your last uwu", backlog.platform.context().window);
}
}
ig.end();
if (ig.begin("list of textures", null, .{})) {
var iterator = rctx.textureList.map.iterator();
while (iterator.next()) |i| {
ig.textf("{s}", .{i.value_ptr.*.name.utf8()});
}
}
ig.end();
if (ig.begin("list of meshes", null, .{})) {
ig.textf("number of meshes: {d}", .{rctx.meshPool.installedMeshes.count()});
var iterator = rctx.meshPool.installedMeshes.iterator();
while (iterator.next()) |i| {
ig.textf("{s}", .{i.value_ptr.*.name.utf8()});
}
} }
ig.end(); ig.end();
} }
@ -86,3 +107,4 @@ const core = backlog.core;
const imgui = backlog.imgui; const imgui = backlog.imgui;
const rend = backlog.rend; const rend = backlog.rend;
const ig = imgui.api; const ig = imgui.api;
const platform = backlog.platform;

View File

@ -14,8 +14,8 @@ showWindow: bool = true,
fpcamera: *FpCamera = undefined, fpcamera: *FpCamera = undefined,
videoplayer: *VideoPlayer = undefined, // videoplayer: *VideoPlayer = undefined,
videoplayerObject: core.Entity = undefined, // videoplayerObject: core.Entity = undefined,
objectSpawner: *extras.ObjectSpawner = undefined, objectSpawner: *extras.ObjectSpawner = undefined,
@ -212,9 +212,9 @@ pub fn prepare(self: *@This()) !void {
ui.context().drawDebug = true; ui.context().drawDebug = true;
try assets.loadList(assetReferences); try assets.loadList(assetReferences);
self.videoplayer = try VideoPlayer.create(self.allocator); // self.videoplayer = try VideoPlayer.create(self.allocator);
try self.videoplayer.startPlayback("LAPWING2.ogv"); // try self.videoplayer.startPlayback("LAPWING2.ogv");
self.videoplayerObject = try self.videoplayer.createVideoPlayerEntity(); // self.videoplayerObject = try self.videoplayer.createVideoPlayerEntity();
rend.setSkyboxTexture("t_skybox"); rend.setSkyboxTexture("t_skybox");
@ -407,8 +407,6 @@ pub fn tryLoadExtern(self: *@This(), gameName: []const u8) !void {
pub fn tick(self: *@This(), dt: f64) void { pub fn tick(self: *@This(), dt: f64) void {
const fdt: f32 = @floatCast(dt); const fdt: f32 = @floatCast(dt);
_ = ig.dockSpaceOverViewport(ig.getMainViewport(), .{ .passthru_central_node = true }, null);
// self.loadMap2() catch unreachable; // self.loadMap2() catch unreachable;
core.loopDelay(@src(), 1.0, dt, struct { core.loopDelay(@src(), 1.0, dt, struct {
@ -427,7 +425,7 @@ pub fn tick(self: *@This(), dt: f64) void {
z2.End(); z2.End();
const z3 = tracy.ZoneN(@src(), "VideoPlayer"); const z3 = tracy.ZoneN(@src(), "VideoPlayer");
self.videoplayer.tick(dt); //self.videoplayer.tick(dt);
z3.End(); z3.End();
const z4 = tracy.ZoneN(@src(), "fpCamera"); const z4 = tracy.ZoneN(@src(), "fpCamera");
@ -473,11 +471,11 @@ pub fn tick(self: *@This(), dt: f64) void {
self.rendererDebugger.tick(dt); self.rendererDebugger.tick(dt);
if (ig.begin("meh", null, .{})) { if (ig.begin("meh", null, .{})) {
ig.textFmt("x:{d:.03} y:{d:.03} z:{d:.03}", .{ pos.x, pos.y, pos.z }) catch return; ig.textFmt("x:{d:.03} y:{d:.03} z:{d:.03}", .{ pos.x, pos.y, pos.z }) catch return;
if (ig.checkbox("video fullbright", &self.videoFullbright)) { // if (ig.checkbox("video fullbright", &self.videoFullbright)) {
if (self.videoplayerObject.fetch(rend.MeshComponent)) |mesh| { // //if (self.videoplayerObject.fetch(rend.MeshComponent)) |mesh| {
mesh.textureMode.fullbright = self.videoFullbright; // // mesh.textureMode.fullbright = self.videoFullbright;
} // //}
} // }
if (ig.checkbox("move lights ", &self.moveLight)) {} if (ig.checkbox("move lights ", &self.moveLight)) {}
@ -521,6 +519,11 @@ pub fn tick(self: *@This(), dt: f64) void {
for (core.Scene.BaseContainer.dense.items) |*v| { for (core.Scene.BaseContainer.dense.items) |*v| {
ig.textFmt("scene entity: {d}", .{v.value.handle.index}) catch unreachable; ig.textFmt("scene entity: {d}", .{v.value.handle.index}) catch unreachable;
} }
ig.textf("window at 0x{x}", .{@intFromPtr(backlog.platform.context().window)});
if (ig.smallButton("click to show sdl messagebox")) {
// _ = backlog.platform.windowing.sdl3.c.SDL_ShowSimpleMessageBox(0, "lmao", "you lmaoed your last uwu", backlog.platform.context().window);
}
} }
ig.end(); ig.end();
} }
@ -533,7 +536,7 @@ pub fn deinit(self: *@This()) void {
self.fpcamera.destroy(); self.fpcamera.destroy();
self.objectSpawner.destroy(); self.objectSpawner.destroy();
self.videoplayer.destroy(); // self.videoplayer.destroy();
self.allocator.destroy(self); self.allocator.destroy(self);
} }
@ -558,7 +561,7 @@ pub fn main() anyerror!void {
} }
const DoomPlayer = @import("doomplayer"); const DoomPlayer = @import("doomplayer");
const VideoPlayer = @import("videoplayer"); //const VideoPlayer = @import("videoplayer");
const extras = @import("gameExtras"); const extras = @import("gameExtras");
const bsp = @import("bsp"); const bsp = @import("bsp");

View File

@ -0,0 +1 @@
zig build --watch --prominent-compile-errors -freference-trace install