summaryrefslogtreecommitdiffstats
path: root/openglscene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'openglscene.cpp')
-rw-r--r--openglscene.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/openglscene.cpp b/openglscene.cpp
index f0c4c79..eb4f1ae 100644
--- a/openglscene.cpp
+++ b/openglscene.cpp
@@ -2,11 +2,16 @@
#include "model.h"
-#include "GL/gl.h"
-#include "GL/glu.h"
-
#include <QtGui>
-#include <QGLContext>
+#include <QtOpenGL>
+
+#ifndef QT_NO_CONCURRENT
+#include <QFutureWatcher>
+#endif
+
+#ifndef GL_MULTISAMPLE
+#define GL_MULTISAMPLE 0x809D
+#endif
class Controls : public QGroupBox
{
@@ -23,7 +28,9 @@ private slots:
private:
OpenGLScene *m_scene;
+#ifndef QT_NO_CONCURRENT
QFutureWatcher<Model *> m_modelLoader;
+#endif
QComboBox *m_models;
QRgb m_modelColor;
@@ -44,7 +51,9 @@ Controls::Controls(OpenGLScene *scene)
dir.setNameFilters(QStringList() << "*.obj");
m_models->addItems(dir.entryList());
connect(m_models, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(loadModel(const QString &)));
+#ifndef QT_NO_CONCURRENT
connect(&m_modelLoader, SIGNAL(finished()), this, SLOT(modelLoaded()));
+#endif
if (m_models->count() > 0)
loadModel(m_models->currentText());
@@ -91,14 +100,21 @@ Model *loadModel(const QString &filename)
void Controls::loadModel(const QString &filename)
{
- m_modelLoader.setFuture(QtConcurrent::run(::loadModel, filename));
m_models->setEnabled(false);
QApplication::setOverrideCursor(Qt::BusyCursor);
+#ifndef QT_NO_CONCURRENT
+ m_modelLoader.setFuture(QtConcurrent::run(::loadModel, filename));
+#else
+ m_scene->setModel(::loadModel(filename));
+ modelLoaded();
+#endif
}
void Controls::modelLoaded()
{
+#ifndef QT_NO_CONCURRENT
m_scene->setModel(m_modelLoader.result());
+#endif
m_models->setEnabled(true);
QApplication::restoreOverrideCursor();
}
@@ -124,9 +140,9 @@ OpenGLScene::OpenGLScene()
, m_normalsEnabled(false)
, m_autoRotate(true)
, m_rotating(false)
- , m_axis(0.5, 1, 0.1)
- , m_angle(0.2)
- , m_distance(1.5)
+ , m_axis(0.5f, 1.0f, 0.1f)
+ , m_angle(0.2f)
+ , m_distance(1.5f)
, m_model(0)
{
// set identity matrix