From fa92a2874943b1596c1298b2248d89f0f17db840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 6 Feb 2019 10:15:48 +0100 Subject: [PATCH] Removed remaining glut parts from OpenMesh QGLViewer --- src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc | 27 ++++++++++++------- src/OpenMesh/Apps/QtViewer/meshviewer.cc | 9 ------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc b/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc index 4e9c65e7..ec2ce252 100644 --- a/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc +++ b/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc @@ -52,11 +52,7 @@ #include #include // -------------------- -#ifdef ARCH_DARWIN -# include -#else -# include -#endif + // -------------------- #include #include @@ -266,21 +262,21 @@ QGLViewerWidget::draw_scene(const std::string& _draw_mode) if (_draw_mode == "Wireframe") { glDisable(GL_LIGHTING); - glutWireTeapot(0.5); + // glutWireTeapot(0.5); } else if (_draw_mode == "Solid Flat") { glEnable(GL_LIGHTING); glShadeModel(GL_FLAT); - glutSolidTeapot(0.5); + //glutSolidTeapot(0.5); } else if (_draw_mode == "Solid Smooth") { glEnable(GL_LIGHTING); glShadeModel(GL_SMOOTH); - glutSolidTeapot(0.5); + //glutSolidTeapot(0.5); } } @@ -585,8 +581,19 @@ QGLViewerWidget::update_projection_matrix() makeCurrent(); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); - gluPerspective(45.0, (GLfloat) width() / (GLfloat) height(), - 0.01*radius_, 100.0*radius_); + + const double fovY = 45.0; + const double aspect = static_cast(width()) / static_cast(height()); + const double zNear = 0.01*radius_; + const double zFar = 100.0*radius_; + +// Replacement for: gluPerspective(45.0, (GLfloat) width() / (GLfloat) height(), 0.01*radius_, 100.0*radius_); + const double pi = 3.1415926535897932384626433832795; + const double fH = tan( fovY / 360 * pi ) * zNear; + const double fW = fH * aspect; + glFrustum( -fW, fW, -fH, fH, zNear, zFar ); + + glGetDoublev( GL_PROJECTION_MATRIX, projection_matrix_); glMatrixMode( GL_MODELVIEW ); } diff --git a/src/OpenMesh/Apps/QtViewer/meshviewer.cc b/src/OpenMesh/Apps/QtViewer/meshviewer.cc index 691f87bc..a3649154 100644 --- a/src/OpenMesh/Apps/QtViewer/meshviewer.cc +++ b/src/OpenMesh/Apps/QtViewer/meshviewer.cc @@ -51,12 +51,6 @@ #include #include -#ifdef ARCH_DARWIN -#include -#else -#include -#endif - #include "MeshViewerWidget.hh" @@ -68,9 +62,6 @@ int main(int argc, char **argv) // OpenGL check QApplication::setColorSpec( QApplication::CustomColor ); QApplication app(argc,argv); -#if !defined(__APPLE__) - glutInit(&argc,argv); -#endif if ( !QGLFormat::hasOpenGL() ) { QString msg = "System has no OpenGL support!";