From a3ab9c3c56888745df575b7640478c8547e0633a Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Sat, 17 Jul 2010 12:15:41 +0200 Subject: Fixes build on mac and path resolving for resources. --- ogrewidget.cpp | 20 ++++++++++++++++++-- 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 #include #include +#include +#include #if defined(Q_WS_X11) #include #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 -- cgit v1.2.3