From da829a43b9ab76ce8830bd83760e59f016787727 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Mon, 15 Oct 2018 23:21:27 +0100 Subject: [PATCH] Allow upside-down(ish) camera angles --- main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.cpp b/main.cpp index 0b53eee..4c9171a 100644 --- a/main.cpp +++ b/main.cpp @@ -149,6 +149,7 @@ void drawTeapot(TeapotProjection proj, bool rotate, float d, glm::vec3 lightPos, } void display() { + glClearColor(0.5, 0.5, 0.5, 1); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); float d = (float)glutGet(GLUT_ELAPSED_TIME) * 0.001f; @@ -531,6 +532,12 @@ void motion(int x, int y) { front.y = sin(pitch); front.z = cos(pitch) * sin(yaw); camFront = glm::normalize(front); + + if (pitch < -1.57079632679 || pitch >= 1.57079632679) { + camUp = glm::vec3(0, -1, 0); + } else { + camUp = glm::vec3(0, 1, 0); + } } void mouse(int button, int state, int x, int y) { -- 2.30.2