camera.y_rot += ~~(last_mouse_x - mx) / 400.0f;
camera.x_rot += ~~(my - last_mouse_y) / 400.0f;
+ while camera.y_rot >= 2 * math.PI do camera.y_rot -= 2 * math.PI;
+ while camera.y_rot < 0 do camera.y_rot += 2 * math.PI;
camera.x_rot = math.clamp(camera.x_rot, -math.PI / 2 + 0.1, math.PI / 2 - 0.1);
speed := 5 * dt;
camera.position -= Vector3.norm(Vector3.cross(facing, .{0,1,0})) * speed;
}
+
+
+ {
+ #persist last_debug_key := 0;
+ debug_key := glfwGetKey(window, GLFW_KEY_F7);
+ if debug_key == GLFW_RELEASE && last_debug_key == GLFW_PRESS {
+ debug_screen = !debug_screen;
+ }
+ last_debug_key = debug_key;
+ }
+
update_world_matrix();
}
+debug_screen := true;
game_fps: i32;
draw :: () {
shader_use(world_shader);
world_draw(world);
- font_print(font, 0, 32, "FPS: {}", game_fps);
+ if debug_screen {
+ font_print(font, 0, 32, "FPS: {}", game_fps);
+ font_print(font, 0, 64, "Position: {}", camera.position);
+ font_print(font, 0, 96, "Facing: {}", camera.y_rot * 180 / math.PI);
+ }
glfwSwapBuffers(window);
}