1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
5 * Tecorrec is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * Tecorrec is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Tecorrec. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
21 * @file tcViewportWidget.cpp
22 * @brief OpenGL viewport widget.
25 #include "tcViewportWidget.h"
26 #include <tcObserver.h>
30 * Constructors + destructor
33 /// Primary constructor.
34 tcViewportWidget::tcViewportWidget(QWidget
* parent
)
36 , m_observer(new tcObserver())
42 tcViewportWidget::~tcViewportWidget()
51 /// Set the globe object.
52 void tcViewportWidget::setGlobe(tcGlobe
* globe
)
61 void tcViewportWidget::initializeGL()
63 glClearColor(0.0, 0.5, 1.0, 0.0);
66 void tcViewportWidget::resizeGL(int w
, int h
)
68 glViewport(0, 0, (GLint
)w
, (GLint
)h
);
70 double aspect
= (double)w
/ h
;
73 glMatrixMode(GL_PROJECTION
);
75 glFrustum(-100.0*aspect
, 100.0*aspect
, -100.0, 100.0, 100.0, 20000e3
);
76 glMatrixMode(GL_MODELVIEW
);
79 void tcViewportWidget::paintGL()
81 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
82 glEnable(GL_DEPTH_TEST
);
88 glTranslatef(0.0f
, 0.0f
, -10000e3
);
89 glRotatef(35.0f
, -1.0f
, 0.0f
, 0.0f
);
91 m_globe
->render(m_observer
);