diff options
author | Giles Bathgate <gilesbathgate@gmail.com> | 2011-05-14 16:10:22 (GMT) |
---|---|---|
committer | Giles Bathgate <gilesbathgate@gmail.com> | 2011-05-14 16:10:22 (GMT) |
commit | b269b5733b7d8adbb5045568a2f994e35d685b86 (patch) | |
tree | 5b057c763fe24cad1f3f7eb226a50ee320bf5e81 /src | |
parent | f698f2ad7ecd8d8c7890c3435eab3259ade09470 (diff) |
Move perspective setup into resize function, still needs to be called in paint when displaying axes.
Diffstat (limited to 'src')
-rw-r--r-- | src/glview.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/glview.cc b/src/glview.cc index 3a4218a..f2bc282 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -228,15 +228,12 @@ void GLView::resizeGL(int w, int h) #endif glViewport(0, 0, w, h); w_h_ratio = sqrt((double)w / (double)h); + + setupPerspective(); } -void GLView::paintGL() +void GLView::setupPerspective() { - const QColor &bgcol = Preferences::inst()->color(Preferences::BACKGROUND_COLOR); - glClearColor(bgcol.redF(), bgcol.greenF(), bgcol.blueF(), 0.0); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (orthomode) @@ -245,6 +242,15 @@ void GLView::paintGL() -FAR_FAR_AWAY, +FAR_FAR_AWAY); else glFrustum(-w_h_ratio, +w_h_ratio, -(1/w_h_ratio), +(1/w_h_ratio), +10.0, +FAR_FAR_AWAY); +} + +void GLView::paintGL() +{ + const QColor &bgcol = Preferences::inst()->color(Preferences::BACKGROUND_COLOR); + glClearColor(bgcol.redF(), bgcol.greenF(), bgcol.blueF(), 0.0); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + gluLookAt(0.0, -viewer_distance, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glMatrixMode(GL_MODELVIEW); @@ -374,6 +380,9 @@ void GLView::paintGL() glVertex3d(zlabel_x-3, zlabel_y+3, 0); glVertex3d(zlabel_x+3, zlabel_y+3, 0); glVertex3d(zlabel_x-3, zlabel_y-3, 0); glVertex3d(zlabel_x+3, zlabel_y+3, 0); glEnd(); + + //Restore perspective for next paint + setupPerspective(); } if (statusLabel) { |