From 32af1de3ac9510316b08809d2d549dc724452020 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 5 Sep 2013 12:34:25 -0700 Subject: [PATCH] For clarity, break the projection matrix update out of resizeGL. --- interface/src/Application.cpp | 23 +++++++++++++---------- interface/src/Application.h | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8156347bba..eefbc69d25 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -428,10 +428,14 @@ void Application::resizeGL(int width, int height) { glViewport(0, 0, width, height); // shouldn't this account for the menu??? + updateProjectionMatrix(); + glLoadIdentity(); +} + +void Application::updateProjectionMatrix() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); - // On window reshape, we need to tell OpenGL about our new setting float left, right, bottom, top, nearVal, farVal; glm::vec4 nearClipPlane, farClipPlane; _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); @@ -445,7 +449,6 @@ void Application::resizeGL(int width, int height) { glFrustum(left, right, bottom, top, nearVal, farVal); glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); } void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes, @@ -613,7 +616,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } else { _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0.001, 0)); } - resizeGL(_glWidget->width(), _glWidget->height()); + updateProjectionMatrix(); break; case Qt::Key_K: @@ -623,7 +626,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } else { _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, -0.001, 0)); } - resizeGL(_glWidget->width(), _glWidget->height()); + updateProjectionMatrix(); break; case Qt::Key_J: @@ -633,7 +636,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } else { _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0)); } - resizeGL(_glWidget->width(), _glWidget->height()); + updateProjectionMatrix(); break; case Qt::Key_M: @@ -643,7 +646,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } else { _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0)); } - resizeGL(_glWidget->width(), _glWidget->height()); + updateProjectionMatrix(); break; case Qt::Key_U: @@ -653,7 +656,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } else { _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0, -0.001)); } - resizeGL(_glWidget->width(), _glWidget->height()); + updateProjectionMatrix(); break; case Qt::Key_Y: @@ -663,7 +666,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } else { _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0, 0.001)); } - resizeGL(_glWidget->width(), _glWidget->height()); + updateProjectionMatrix(); break; case Qt::Key_H: Menu::getInstance()->triggerOption(MenuOption::Mirror); @@ -1806,12 +1809,12 @@ void Application::update(float deltaTime) { const float EYE_OFFSET_SCALE = 0.005f; glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE; _myCamera.setEyeOffsetPosition(glm::vec3(-position.x, position.y, position.z)); - resizeGL(_glWidget->width(), _glWidget->height()); + updateProjectionMatrix(); } else if (_webcam.isActive()) { const float EYE_OFFSET_SCALE = 5.0f; _myCamera.setEyeOffsetPosition(_webcam.getEstimatedPosition() * EYE_OFFSET_SCALE); - resizeGL(_glWidget->width(), _glWidget->height()); + updateProjectionMatrix(); } } } diff --git a/interface/src/Application.h b/interface/src/Application.h index 2d88bca73c..0630d3cbca 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -178,6 +178,7 @@ private slots: private: void resetCamerasOnResizeGL(Camera& camera, int width, int height); + void updateProjectionMatrix(); static bool sendVoxelsOperation(VoxelNode* node, void* extraData); static void processAvatarVoxelURLMessage(unsigned char* packetData, size_t dataBytes);