aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2025-09-22 15:31:24 +0000
committers-ol <s+removethis@s-ol.nu>2025-09-22 15:31:24 +0000
commit16536b73befacf131065ff8eb97179433f24f3d1 (patch)
tree7a4d5d929f05de48c0a05ebccca7c333e0b80ce7
parentlog errors in threads (diff)
downloadglsl-view-16536b73befacf131065ff8eb97179433f24f3d1.tar.gz
glsl-view-16536b73befacf131065ff8eb97179433f24f3d1.zip
log fps every 64 frames
-rw-r--r--src/main.zig23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/main.zig b/src/main.zig
index aeae96e..6d70a14 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -117,6 +117,7 @@ pub fn main() !void {
const control = try ctrl.ControlServer.init(cfg_allocator, progress, &cache, &config, &constants);
defer control.destroy();
+ var loops: u8 = 0;
while (c.glfwWindowShouldClose(window) == c.GL_FALSE) {
c.glfwMakeContextCurrent(window);
@@ -134,12 +135,24 @@ pub fn main() !void {
// control.reload_requested = false;
// }
- fbo.bind();
- c.glClear(c.GL_COLOR_BUFFER_BIT);
+ {
+ c.glFinish();
+ var timer = try std.time.Timer.start();
- main_program.bind();
- constants.normalized_quad.draw();
- fbo.unbind();
+ fbo.bind();
+ c.glClear(c.GL_COLOR_BUFFER_BIT);
+
+ main_program.bind();
+ constants.normalized_quad.draw();
+ fbo.unbind();
+
+ c.glFinish();
+ const fps = timer.read(); // ns
+ loops = (loops + 1) % 64;
+ if (loops == 0) {
+ std.debug.print("\rrendered in {d:.2}ms\n", .{@as(f64, @floatFromInt(fps)) / std.time.ns_per_ms});
+ }
+ }
for (outputs.items, 0..) |output, i| {
const close = output.update(fbo.texture_id);