From 92db0ece25140a517f5692869bd5bae47a102523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 23 Jun 2008 13:57:49 +0200 Subject: Compile on MSVC6. --- model.cpp | 16 ++++++++-------- openglscene.cpp | 32 ++++++++++++++++++++++++-------- openglscene.h | 1 - 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/model.cpp b/model.cpp index 1af3c5a..38e09ab 100644 --- a/model.cpp +++ b/model.cpp @@ -5,7 +5,7 @@ #include #include -#include "GL/gl.h" +#include struct Edge { @@ -36,8 +36,8 @@ Model::Model(const QString &filename) // use a set to avoid duplicate edges QSet edges; - Point3d min( 1e9, 1e9, 1e9); - Point3d max(-1e9,-1e9,-1e9); + Point3d boundsMin( 1e9, 1e9, 1e9); + Point3d boundsMax(-1e9,-1e9,-1e9); QTextStream in(&file); while (!in.atEnd()) { @@ -57,8 +57,8 @@ Model::Model(const QString &filename) m_points << p; for (int i = 0; i < 3; ++i) { - min[i] = qMin(min[i], p[i]); - max[i] = qMax(max[i], p[i]); + boundsMin[i] = qMin(boundsMin[i], p[i]); + boundsMax[i] = qMax(boundsMax[i], p[i]); } } else if (id == "f" || id == "fo") { QVarLengthArray p; @@ -86,10 +86,10 @@ Model::Model(const QString &filename) } } - const Point3d bounds = max - min; + const Point3d bounds = boundsMax - boundsMin; const qreal scale = 1 / qMax(bounds.x, qMax(bounds.y, bounds.z)); for (int i = 0; i < m_points.size(); ++i) - m_points[i] = (m_points[i] - (min + bounds * 0.5)) * scale; + m_points[i] = (m_points[i] - (boundsMin + bounds * 0.5)) * scale; m_normals.resize(m_points.size()); for (int i = 0; i < m_pointIndices.size(); i += 3) { @@ -144,7 +144,7 @@ void Model::render(bool wireframe, bool normals) const glBegin(GL_LINES); for (int i = 0; i < m_normals.size(); ++i) { Point3d a = m_points.at(i); - Point3d b = m_points.at(i) + m_normals.at(i) * 0.02; + Point3d b = m_points.at(i) + m_normals.at(i) * 0.02f; glVertex3f(a.x, a.y, a.z); glVertex3f(b.x, b.y, b.z); } 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 -#include +#include + +#ifndef QT_NO_CONCURRENT +#include +#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 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 diff --git a/openglscene.h b/openglscene.h index 15ce85c..7c2c9c4 100644 --- a/openglscene.h +++ b/openglscene.h @@ -3,7 +3,6 @@ #include "point3d.h" -#include #include class Model; -- cgit v1.2.3