return __stack_top;
}
+font_print :: (font: Font, x, y: f32, format: str, va: ..any) {
+ buf: [1024] u8;
+ msg := conv.str_format_va(buf, format, va);
+ font_draw(font, x, y, msg);
+}
+
font_draw :: (font: Font, x, y: f32, msg: str) {
quads: ^stbtt_aligned_quad = alloca(msg.count * sizeof stbtt_aligned_quad);
quad_num := 0;
update_world_matrix();
}
+game_fps: i32;
+
draw :: () {
glClearColor(.7, .7, .9, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shader_use(world_shader);
world_draw(world);
- font_draw(font, 100, 100, "Hello!");
+ font_print(font, 0, 32, "FPS: {}", game_fps);
glfwSwapBuffers(window);
}
last := glfwGetTime();
now := last;
+ seconds := 0.0;
+ frame_count := 0;
+
while !glfwWindowShouldClose(window) {
glfwPollEvents();
now = glfwGetTime();
dt := now - last;
last = now;
+
+ seconds += dt;
+ frame_count += 1;
+ if seconds >= 1 {
+ game_fps = ~~frame_count;
+ seconds -= 1;
+ frame_count = 0;
+ }
+
update(~~dt);
draw();
}