Index: new-game.cpp
===================================================================
--- new-game.cpp	(revision 14ff67c4e0dcfe093de8b89d89b47e028af8f03b)
+++ new-game.cpp	(revision 4f3262fbb197a9d1018a6b3e0a52f8a9bcf81131)
@@ -91,4 +91,8 @@
 ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
 
+void glfw_error_callback(int error, const char* description);
+
+void mouse_button_callback(GLFWwindow* window, int button, int action, int mods);
+
 bool faceClicked(array<vec3, 3> points, SceneObject* obj, vec4 world_ray, vec4 cam, vec4& click_point);
 bool insideTriangle(vec3 p, array<vec3, 3> triangle_points);
@@ -111,62 +115,4 @@
                   SceneObject* selectedObject);
 void renderSceneGui();
-
-void glfw_error_callback(int error, const char* description) {
-   gl_log_err("GLFW ERROR: code %i msg: %s\n", error, description);
-}
-
-void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) {
-   double mouse_x, mouse_y;
-   glfwGetCursorPos(window, &mouse_x, &mouse_y);
-
-   if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
-      cout << "Mouse clicked (" << mouse_x << "," << mouse_y << ")" << endl;
-      selectedObject = NULL;
-
-      float x = (2.0f*mouse_x) / width - 1.0f;
-      float y = 1.0f - (2.0f*mouse_y) / height;
-
-      cout << "x: " << x << ", y: " << y << endl;
-
-      vec4 ray_clip = vec4(x, y, -1.0f, 1.0f);
-      vec4 ray_eye = inverse(proj_mat) * ray_clip;
-      ray_eye = vec4(ray_eye.xy(), -1.0f, 1.0f);
-      vec4 ray_world = inverse(view_mat) * ray_eye;
-
-      vec4 cam_pos_temp = vec4(cam_pos, 1.0f);
-
-      vec4 click_point;
-      vec3 closest_point = vec3(0.0f, 0.0f, -FAR_CLIP); // Any valid point will be closer than the far clipping plane, so initial value to that
-      SceneObject* closest_object = NULL;
-
-      SceneObject* obj;
-      for (vector<SceneObject>::iterator it = objects.begin(); it != objects.end(); it++) {
-         obj = &*it;
-
-         for (unsigned int p_idx = 0; p_idx < it->points.size(); p_idx += 9) {
-            if (faceClicked({
-               vec3(it->points[p_idx], it->points[p_idx + 1], it->points[p_idx + 2]),
-               vec3(it->points[p_idx + 3], it->points[p_idx + 4], it->points[p_idx + 5]),
-               vec3(it->points[p_idx + 6], it->points[p_idx + 7], it->points[p_idx + 8]),
-            },
-            obj, ray_world, cam_pos_temp, click_point)) {
-               click_point = view_mat * click_point;
-
-               if (-NEAR_CLIP >= click_point.z && click_point.z > -FAR_CLIP && click_point.z > closest_point.z) {
-                  closest_point = click_point.xyz();
-                  closest_object = obj;
-               }
-            }
-         }
-      }
-
-      if (closest_object == NULL) {
-         cout << "No object was clicked" << endl;
-      } else {
-         clickedObject = closest_object;
-         cout << "Clicked object: " << clickedObject->id << endl;
-      }
-   }
-}
 
 int main(int argc, char* argv[]) {
@@ -761,4 +707,63 @@
 }
 
+void glfw_error_callback(int error, const char* description) {
+   gl_log_err("GLFW ERROR: code %i msg: %s\n", error, description);
+}
+
+void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) {
+   double mouse_x, mouse_y;
+   glfwGetCursorPos(window, &mouse_x, &mouse_y);
+
+   if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
+      cout << "Mouse clicked (" << mouse_x << "," << mouse_y << ")" << endl;
+      selectedObject = NULL;
+
+      float x = (2.0f*mouse_x) / width - 1.0f;
+      float y = 1.0f - (2.0f*mouse_y) / height;
+
+      cout << "x: " << x << ", y: " << y << endl;
+
+      vec4 ray_clip = vec4(x, y, -1.0f, 1.0f);
+      vec4 ray_eye = inverse(proj_mat) * ray_clip;
+      ray_eye = vec4(ray_eye.xy(), -1.0f, 1.0f);
+      vec4 ray_world = inverse(view_mat) * ray_eye;
+
+      vec4 cam_pos_temp = vec4(cam_pos, 1.0f);
+
+      vec4 click_point;
+      vec3 closest_point = vec3(0.0f, 0.0f, -FAR_CLIP); // Any valid point will be closer than the far clipping plane, so initial value to that
+      SceneObject* closest_object = NULL;
+
+      SceneObject* obj;
+      for (vector<SceneObject>::iterator it = objects.begin(); it != objects.end(); it++) {
+         obj = &*it;
+
+         for (unsigned int p_idx = 0; p_idx < it->points.size(); p_idx += 9) {
+            if (faceClicked({
+               vec3(it->points[p_idx], it->points[p_idx + 1], it->points[p_idx + 2]),
+               vec3(it->points[p_idx + 3], it->points[p_idx + 4], it->points[p_idx + 5]),
+               vec3(it->points[p_idx + 6], it->points[p_idx + 7], it->points[p_idx + 8]),
+               },
+               obj, ray_world, cam_pos_temp, click_point)) {
+               click_point = view_mat * click_point;
+
+               if (-NEAR_CLIP >= click_point.z && click_point.z > -FAR_CLIP && click_point.z > closest_point.z) {
+                  closest_point = click_point.xyz();
+                  closest_object = obj;
+               }
+            }
+         }
+      }
+
+      if (closest_object == NULL) {
+         cout << "No object was clicked" << endl;
+      }
+      else {
+         clickedObject = closest_object;
+         cout << "Clicked object: " << clickedObject->id << endl;
+      }
+   }
+}
+
 GLuint loadShader(GLenum type, string file) {
   cout << "Loading shader from file " << file << endl;
