89 lines
2.5 KiB
Zig
89 lines
2.5 KiB
Zig
pub export fn startup(p_allocator: *anyopaque, p_a: ?*anyopaque) bool {
|
|
const allocator = core.modulePreamble(p_allocator, p_a) catch return false;
|
|
_ = allocator;
|
|
imgui.setupFromModule();
|
|
|
|
start_module(core.startup_getArgs(p_a.?)) catch return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
pub export fn add(a: i32, b: i32) i32 {
|
|
return a + b;
|
|
}
|
|
|
|
pub export fn subtract(a: i32, b: i32) i32 {
|
|
return a + b;
|
|
}
|
|
|
|
var gAllocator: std.mem.Allocator = undefined;
|
|
|
|
pub fn log(comptime fmt: []const u8, args: anytype) void {
|
|
core.engine_log("[ExternGame]: " ++ fmt, args);
|
|
}
|
|
|
|
fn start_module(args: core.ModuleLoaderArgs) !void {
|
|
if (args.firstLoad) {
|
|
_ = core.createObject(ExternGameObject, .{}) catch {};
|
|
return;
|
|
}
|
|
|
|
log("extern game reloaded ", .{});
|
|
log("hello mother fucker", .{});
|
|
log("accessing old object at {x} same object? {d}", .{ @intFromPtr(core.EngineObject(ExternGameObject).get()), @sizeOf(ExternGameObject) });
|
|
|
|
log("gonna try something dumb- lets patch the vtable of that old object with my vtable's values", .{});
|
|
const ref = core.getEngineObjectRef(ExternGameObject).?;
|
|
|
|
ref.vtable.tick_func = ExternGameObject.NeonObjectTable.tick_func;
|
|
}
|
|
|
|
pub const ExternGameObject = struct {
|
|
pub var NeonObjectTable = core.EngineObjectVTable.from(@This(), "game.ExternGameObject");
|
|
|
|
allocator: std.mem.Allocator,
|
|
|
|
pub fn create(allocator: std.mem.Allocator) !*@This() {
|
|
const self = try allocator.create(@This());
|
|
self.* = .{ .allocator = allocator };
|
|
|
|
return self;
|
|
}
|
|
|
|
pub fn tick(self: *@This(), dt: f64) void {
|
|
_ = self;
|
|
_ = dt;
|
|
if (ig.begin("external game object", null, .{})) {
|
|
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.textf("sup", .{});
|
|
ig.textf("hello !", .{});
|
|
ig.textf("sup", .{});
|
|
ig.textf("hello !", .{});
|
|
|
|
_ = ig.sliderFloat("skybox red", &rend.context().skyboxSystem.brightnessFactor, 0, 200, null, .{});
|
|
}
|
|
ig.end();
|
|
}
|
|
|
|
pub fn destroy(self: *@This()) void {
|
|
self.allocator.destroy(self);
|
|
}
|
|
};
|
|
|
|
pub export fn shutdown() void {}
|
|
|
|
const std = @import("std");
|
|
const backlog = @import("backlog");
|
|
const core = backlog.core;
|
|
const imgui = backlog.imgui;
|
|
const rend = backlog.rend;
|
|
const ig = imgui.api;
|