diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2010-07-17 12:15:41 +0200 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@nokia.com> | 2010-07-17 12:15:41 +0200 |
commit | a3ab9c3c56888745df575b7640478c8547e0633a (patch) | |
tree | 96470734bc958d2d8dd513417c1527069ca0ed25 | |
parent | 309c0d791a4d11d84a90985b48a2ed1fac21224b (diff) |
Fixes build on mac and path resolving for resources.
-rw-r--r-- | ogrewidget.cpp | 20 | ||||
-rw-r--r-- | qmlogre.pro | 41 |
2 files changed, 45 insertions, 16 deletions
diff --git a/ogrewidget.cpp b/ogrewidget.cpp index 2c43a26..c42bb62 100644 --- a/ogrewidget.cpp +++ b/ogrewidget.cpp @@ -13,11 +13,27 @@ #include <OgreMaterialManager.h> #include <QtDeclarative/QDeclarativeContext> #include <QtCore/QDebug> +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> #if defined(Q_WS_X11) #include <QX11Info> #endif +static QString appPath() +{ + QString path = QCoreApplication::applicationDirPath(); + QDir dir(path); +#ifdef Q_WS_MAC + dir.cdUp(); + dir.cdUp(); + dir.cdUp(); +#elif defined(Q_WS_WIN) + dir.cdUp(); +#endif + return dir.absolutePath(); +} + OgreWidget::OgreWidget(QWidget *parent) : QGLWidget(parent), m_root(0), @@ -111,7 +127,7 @@ void OgreWidget::initializeGL() m_QmlUI = new DeclarativeViewTexture(this); m_QmlUI->setResizeMode(QDeclarativeView::SizeRootObjectToView); - m_QmlUI->setSource(QUrl("resources/example.qml")); + m_QmlUI->setSource(QUrl(QString(appPath() + "/resources/example.qml"))); m_QmlUI->rootContext()->setContextProperty("Camera", m_cameraObject); m_QmlUI->rootContext()->setContextProperty("Window", this); } @@ -175,7 +191,7 @@ void OgreWidget::initOgre() m_renderWindow->setVisible(true); // Load resources - Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resources/data.zip", "Zip"); + Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(appPath() + "/resources/data.zip").toAscii().data(), "Zip"); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); // Setup scene diff --git a/qmlogre.pro b/qmlogre.pro index 9f1ad7a..31b41a9 100644 --- a/qmlogre.pro +++ b/qmlogre.pro @@ -3,35 +3,48 @@ QT += opengl declarative TEMPLATE = app TARGET = qmlogre -unix { +macx { + OGREDIR = $$(OGRE_HOME) + isEmpty(OGREDIR) { + error(QmlOgre needs Ogre to be built. Please set the environment variable OGRE_HOME pointing to your Ogre root directory.) + } else { + message(Using Ogre libraries in $$OGREDIR) + INCLUDEPATH += $$OGREDIR/include/OGRE + QMAKE_LFLAGS += -F$$OGREDIR/lib/release + LIBS += -framework Ogre + + BOOSTDIR = $$OGREDIR/boost_1_42 + !isEmpty(BOOSTDIR) { + INCLUDEPATH += $$BOOSTDIR + LIBS += -L$$BOOSTDIR/lib -lboost_date_time-xgcc40-mt-1_42 -lboost_thread-xgcc40-mt-1_42 + } + + DEFINES += OGRE_PLUGIN_VAR=\"$$OGREDIR/lib\" + } +} else:unix { CONFIG += link_pkgconfig PKGCONFIG += OGRE OGRELIBDIR = $$system(pkg-config --libs-only-L OGRE) OGRELIBDIR = $$replace(OGRELIBDIR, -L,) OGREPLUGINDIR = $$OGRELIBDIR/OGRE DEFINES += OGRE_PLUGIN_VAR=\"$$OGREPLUGINDIR\" -} else { +} else:win32 { OGREDIR = $$(OGRE_HOME) isEmpty(OGREDIR) { error(QmlOgre needs Ogre to be built. Please set the environment variable OGRE_HOME pointing to your Ogre root directory.) } else { message(Using Ogre libraries in $$OGREDIR) INCLUDEPATH += $$OGREDIR/include/OGRE - macx { - QMAKE_LFLAGS += -F$$OGREDIR/lib/release - LIBS += -framework Ogre - } else { - LIBS += -L$$OGREDIR/lib -lOgreMain + LIBS += -L$$OGREDIR/lib -lOgreMain + + BOOSTDIR = $$OGREDIR/boost_1_42 + !isEmpty(BOOSTDIR) { + INCLUDEPATH += $$BOOSTDIR + LIBS += -L$$BOOSTDIR/lib -lboost_date_time-xgcc40-mt-1_42 -lboost_thread-xgcc40-mt-1_42 } - } - BOOSTDIR = $$OGREDIR/boost_1_42 - !isEmpty(BOOSTDIR) { - INCLUDEPATH += $$BOOSTDIR - LIBS += -L$$BOOSTDIR/lib -lboost_date_time-xgcc40-mt-1_42 -lboost_thread-xgcc40-mt-1_42 + DEFINES += OGRE_PLUGIN_VAR=\\\"$$OGREDIR/bin\\\" } - - DEFINES += OGRE_PLUGIN_VAR=$$OGREDIR/lib } UI_DIR = ./.ui |