const std = @import("std");
const log = std.log.scoped(.main);
const zopengl = @import("zopengl");
const zglfw = @import("zglfw");
const Shader = @import("shader.zig").Shader;
const Buffers = @import("buffers.zig").Buffers;
const Object = @import("object.zig").Object;
const Camera = @import("camera.zig").Camera;
const Scene = @import("scene.zig").Scene;
const utils = @import("utils.zig");
const gl = zopengl.bindings;
var camera = Camera.init(1024, 768);
fn resizeCallback(
window: *zglfw.Window,
width: i32,
height: i32,
) callconv(.C) void {
_ = window;
gl.viewport(0, 0, width, height);
camera.resize(width, height);
}
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
try zglfw.init();
defer zglfw.terminate();
const window = try utils.newWindow("Jenjin", 1024, 768);
defer window.destroy();
try zopengl.loadCoreProfile(zglfw.getProcAddress, 4, 6);
var scene = try Scene.init(allocator);
defer scene.deinit();
const player = try scene.newObject();
_ = player;
_ = window.setFramebufferSizeCallback(resizeCallback);
while (!window.shouldClose() and window.getKey(.escape) != .press) {
zglfw.pollEvents();
gl.clearBufferfv(gl.COLOR, 0, &[_]f32{ 0.1, 0.1, 0.1, 1.0 });
gl.clear(gl.COLOR);
scene.use(&buffers);
window.swapBuffers();
}
}
If I switch to heap allocation of Object in the Scene struct: