History

For clarity, break the projection matrix update out of resizeGL.

Andrzej Kapolka committed 13 years ago

Commit 32af1de1 parent 49619132 files · +14 −10Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+13−10
@@ -428,10 +428,14 @@ void Application::resizeGL(int width, int height) { · 427 unmodified lines
428428
429429 glViewport(0, 0, width, height); // shouldn't this account for the menu???
430430
431+ updateProjectionMatrix();
432+ glLoadIdentity();
433+}
434+
435+void Application::updateProjectionMatrix() {
431436 glMatrixMode(GL_PROJECTION);
432437 glLoadIdentity();
433438
434− // On window reshape, we need to tell OpenGL about our new setting
435439 float left, right, bottom, top, nearVal, farVal;
436440 glm::vec4 nearClipPlane, farClipPlane;
437441 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
@@ -445,7 +449,6 @@ void Application::resizeGL(int width, int height) { · 7 unmodified lines
445449 glFrustum(left, right, bottom, top, nearVal, farVal);
446450
447451 glMatrixMode(GL_MODELVIEW);
448− glLoadIdentity();
449452 }
450453
451454 void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
@@ -613,7 +616,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 161 unmodified lines
613616 } else {
614617 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0.001, 0));
615618 }
616− resizeGL(_glWidget->width(), _glWidget->height());
619+ updateProjectionMatrix();
617620 break;
618621
619622 case Qt::Key_K:
@@ -623,7 +626,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3 unmodified lines
623626 } else {
624627 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, -0.001, 0));
625628 }
626− resizeGL(_glWidget->width(), _glWidget->height());
629+ updateProjectionMatrix();
627630 break;
628631
629632 case Qt::Key_J:
@@ -633,7 +636,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3 unmodified lines
633636 } else {
634637 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
635638 }
636− resizeGL(_glWidget->width(), _glWidget->height());
639+ updateProjectionMatrix();
637640 break;
638641
639642 case Qt::Key_M:
@@ -643,7 +646,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3 unmodified lines
643646 } else {
644647 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0));
645648 }
646− resizeGL(_glWidget->width(), _glWidget->height());
649+ updateProjectionMatrix();
647650 break;
648651
649652 case Qt::Key_U:
@@ -653,7 +656,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3 unmodified lines
653656 } else {
654657 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0, -0.001));
655658 }
656− resizeGL(_glWidget->width(), _glWidget->height());
659+ updateProjectionMatrix();
657660 break;
658661
659662 case Qt::Key_Y:
@@ -663,7 +666,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3 unmodified lines
663666 } else {
664667 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0, 0.001));
665668 }
666− resizeGL(_glWidget->width(), _glWidget->height());
669+ updateProjectionMatrix();
667670 break;
668671 case Qt::Key_H:
669672 Menu::getInstance()->triggerOption(MenuOption::Mirror);
@@ -1806,12 +1809,12 @@ void Application::update(float deltaTime) { · 1136 unmodified lines
18061809 const float EYE_OFFSET_SCALE = 0.005f;
18071810 glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE;
18081811 _myCamera.setEyeOffsetPosition(glm::vec3(-position.x, position.y, position.z));
1809− resizeGL(_glWidget->width(), _glWidget->height());
1812+ updateProjectionMatrix();
18101813
18111814 } else if (_webcam.isActive()) {
18121815 const float EYE_OFFSET_SCALE = 5.0f;
18131816 _myCamera.setEyeOffsetPosition(_webcam.getEstimatedPosition() * EYE_OFFSET_SCALE);
1814− resizeGL(_glWidget->width(), _glWidget->height());
1817+ updateProjectionMatrix();
18151818 }
18161819 }
18171820 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t