added toggle to debug screen
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 21 Dec 2021 16:11:09 +0000 (10:11 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 21 Dec 2021 16:11:09 +0000 (10:11 -0600)
src/main.onyx

index 747e2c2289d4c56692d0d1f7ca1673fe8465e1f3..2d08686d3e7484547e0b4f1db5a2b8fb0f5a33e1 100644 (file)
@@ -121,6 +121,8 @@ update :: (dt: f32) {
 
     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;
@@ -142,9 +144,21 @@ update :: (dt: f32) {
         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 :: () {
@@ -154,7 +168,11 @@ 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);
 }