void Application::initialise(void) { mOgreWidget->show(); mOgreWidget->resize(800,600); centerWidget(mOgreWidget); centerWidget(mLogManager, mOgreWidget); mLogManager->setForceProcessEvents(true); initialiseOgre(); mLogManager->setForceProcessEvents(false); //mLogManager->hide(); mOgreWidget->setEventHandler(mGameLogic); //This is a bit of a hack, necessary because we want to use the settings dialog in two different //ways. The first time it is shown (by Application::exec()) no slot is connected - the Accepted //event is handled explicitly because the system is not initialised at that point. But now (and //when the dialog is shown in future) we are ready for it, so we connect the accepted() signal. //We also call accept, to do the initial setup. See also Application::exec(). connect(mSettingsDialog, SIGNAL(accepted()), this, SLOT(applySettings())); mSettingsDialog->accept(); Ogre::NameValuePairList ogreWindowParams; //ogreWindowParams["FSAA"] = "8"; mOgreWidget->initialise(&ogreWindowParams); //Set up resource paths. This can't be done until the OgreWidget //is initialised, because we need the GPUProgramManager. if(QFile::exists("resources.cfg")) { loadResourcePathsFromConfigFile("resources.cfg"); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); } mFPSDialog = new FPSDialog(mOgreWidget, Qt::ToolTip); mFPSDialog->setWindowOpacity(settings()->value("System/DefaultWindowOpacity", 1.0).toDouble()); mFPSDialog->move(mainWidget()->geometry().topLeft() + QPoint(10,10)); mLogManager->move(mainWidget()->geometry().left() + 10, mainWidget()->geometry().top() + mainWidget()->geometry().height() - mLogManager->frameGeometry().height() - 10); mGameLogic->initialise(); if(mAutoUpdateEnabled) { mAutoUpdateTimer->start(); } mIsInitialised = true; }
void OgreSys::initialise(void) { initialiseOgre(); //Set up resource paths. This can't be done until the OgreWidget //is initialised, because we need the GPUProgramManager. //if(QFile::exists("resources.cfg")) { loadResourcePathsFromConfigFile("resources.cfg"); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); } mGameLogic->initialise(); }
void Application::initialise( void ) { mOgreWidget->show(); mOgreWidget->resize( 800, 600 ); centerWidget( mOgreWidget ); //mLogManagerDockWidget = mMainWindow->addAsDockWidget(mLogManager, "Logs", Qt::AllDockWidgetAreas); //mLogManager->setParent(mMainWindow); centerWidget( mLogManager, mOgreWidget ); mLogManager->show(); //mLogManager->setForceProcessEvents(true); initialiseOgre(); Ogre::NameValuePairList ogreWindowParams; ogreWindowParams["FSAA"] = "8"; mOgreWidget->initialise( &ogreWindowParams ); mGameLogic->initialise(); //mLogManager->setForceProcessEvents(false); //mLogManager->hide(); mOgreWidget->setEventHandler( mGameLogic ); //This is a bit of a hack, necessary because we want to use the settings dialog in two different //ways. The first time it is shown (by Application::exec()) no slot is connected - the Accepted //event is handled explicitly because the system is not initialised at that point. But now (and //when the dialog is shown in future) we are ready for it, so we connect the accepted() signal. //We also call accept, to do the initial setup. See also Application::exec(). connect( mSettingsDialog, SIGNAL( accepted() ), this, SLOT( applySettings() ) ); mSettingsDialog->accept(); mFPSDialog = new FPSDialog( mOgreWidget, Qt::FramelessWindowHint ); mFPSDialog->setWindowOpacity( settings()->value( "System/DefaultWindowOpacity", 1.0 ).toDouble() ); mFPSDialog->move( mainWidget()->geometry().topLeft() + QPoint( 10, 10 ) ); mFPSDialog->show(); mLogManager->move( mainWidget()->geometry().left() + 10, mainWidget()->geometry().top() + mainWidget()->geometry().height() - mLogManager->frameGeometry().height() - 10 ); mUpdateTimer = new QTimer; QObject::connect( mUpdateTimer, SIGNAL( timeout() ), this, SLOT( update() ) ); //On the test system, a value of one here gives a high frame rate and still allows //event prcessing to take place. A value of 0 doubles the frame rate but the mouse //becomes jumpy. This property should probably be configurable. mUpdateTimer->start( 1 ); }
OgreWidget::OgreWidget(QWidget* pParentWidget, Qt::WindowFlags f) :QWidget(pParentWidget, f | Qt::MSWindowsOwnDC) , mWindow(0) , mpParentWidget(pParentWidget) { QWidget *q_parent = dynamic_cast <QWidget *> (parent()); setMouseTracking(true); //grabKeyboard(); setAttribute(Qt::WA_PaintOnScreen); mRoot = new Ogre::Root(); initialiseOgre(); Ogre::NameValuePairList ogreWindowParams; ogreWindowParams["FSAA"] = "8 (Quality)"; ogreWindowParams["vsync"] = "true"; ogreWindowParams["parentWindowHandle"] = Ogre::StringConverter::toString((unsigned long)this->parentWidget()->winId()); mWindow = Ogre::Root::getSingletonPtr()->createRenderWindow("OgreWindow", width(), height(), false, &ogreWindowParams); mWindow->setActive(true); mWindow->setVisible(true); mWindow->setAutoUpdated(false); WId window_id; mWindow->getCustomAttribute("HWND", &window_id); QWidget::create(window_id); moveAndResize(); mUpdateTimer = new QTimer; QObject::connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(update())); mUpdateTimer->start(10); // Create Ogre Scene chooseSceneManager(); createCamera(); createViewports(); loadResources(); createScene(); }