+static double prev_x, prev_y;
+static bool button[8];
+
+static void clbk_motion(GLFWwindow *win, double x, double y)
+{
+ double dx = x - prev_x;
+ double dy = y - prev_y;
+
+ prev_x = x;
+ prev_y = y;
+
+ if(button[0]) {
+ theta += dx;
+ phi += dy;
+
+ if(phi < -90)
+ phi = -90;
+ if(phi > 90)
+ phi = 90;
+ }
+
+ if(button[1]) {
+ dist += dy;
+ if(dist < 0.0) {
+ dist = 0.0;
+ }
+ }
+}
+
+static void clbk_mouse(GLFWwindow *win, int bn, int action, int mods)
+{
+ button[bn] = action == GLFW_PRESS;
+ glfwGetCursorPos(win, &prev_x, &prev_y);
+}
+
+static void clbk_reshape(GLFWwindow *win, int width, int height)