+ if (key == '0') {
+ curMode = render;
+ needsRedisplay = true;
+ }
+ if (key == '1') {
+ curMode = debugContDist;
+ needsRedisplay = true;
+ }
+ if (key == '2') {
+ curMode = debugColor;
+ needsRedisplay = true;
+ }
+ if (key == '3') {
+ curMode = debugProbAct;
+ needsRedisplay = true;
+ }
+ if (key == '4') {
+ curMode = debugProbExt;
+ needsRedisplay = true;
+ }
+ if (key == 's') {
+ envColorIdx = (envColorIdx + 1) % envColors.size();
+ needsRedisplay = true;
+ curBeenShaded = false;
+ }
+}
+
+int prevMouseX, prevMouseY;
+bool firstMouse = true;
+void motion(int x, int y) {
+ if (firstMouse) {
+ prevMouseX = x;
+ prevMouseY = y;
+ firstMouse = false;
+ }
+ float dx = x - prevMouseX, dy = y - prevMouseY;
+ prevMouseX = x;
+ prevMouseY = y;
+ const vec3 origin(0, 0, 0);
+ const float sensitivity = 0.003f;
+ auto camMat = translate(mat4(1), origin + camPos);
+ auto rotation = rotate(rotate(mat4(1), -dx * sensitivity, {0, 1, 0}),
+ -dy * sensitivity, {1, 0, 0});
+ auto rotAroundOrig = camMat * rotation * translate(mat4(1), origin - camPos);
+ camPos = rotAroundOrig * glm::vec4(camPos, 0);
+ needsRedisplay = true;
+}
+
+void passiveMotion(int x, int y) {
+ prevMouseX = x;
+ prevMouseY = y;
+}
+
+void reshape(int w, int h) {
+ width = w;
+ height = h;