X-Git-Url: http://git.lukelau.me/?p=opengl.git;a=blobdiff_plain;f=main.cpp;h=4c9171ab71a63c726e19996252e402b4e24949e1;hp=0b53eee3aace592eb49e2a730b21f9c77c8c4faa;hb=da829a43b9ab76ce8830bd83760e59f016787727;hpb=5a4d005b668b98d44ef20391ecddaf6bfc2ee70f 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) {