Skip to content

Commit

Permalink
Simplifying use of ApplicationContext framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Joilnen committed Feb 16, 2024
1 parent 7f0566e commit 9b7d88c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
25 changes: 21 additions & 4 deletions Components/Bites/include/OgreApplicationContextBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ namespace OgreBites
*/
virtual void loadResources();

/// @deprecated use do not use
OGRE_DEPRECATED virtual void reconfigure(const Ogre::String& renderer, Ogre::NameValuePairList& options);
/**
Reconfigures the context. Attempts to preserve the current sample state.
*/
virtual void reconfigure(const Ogre::String& renderer, Ogre::NameValuePairList& options);


/**
Expand Down Expand Up @@ -273,10 +275,24 @@ namespace OgreBites
void destroyWindow(const Ogre::String& name);

/**
* get the FileSystemLayer instance pointing to an application specific directory
* get the FileSystemLayer instace pointing to an application specific directory
*/
Ogre::FileSystemLayer& getFSLayer() { return *mFSLayer; }

/**
* main loop
*/
Ogre::FileSystemLayer& getFSLayer() const { return *mFSLayer; }
virtual void mainLoop();

/**
* create Scene Manager
*/
Ogre::SceneManager *createSceneManager(Ogre::String type = Ogre::SMT_DEFAULT);

/**
* get Scene Manager
*/
Ogre::SceneManager *getSceneManager();
/**
* the directory where the media files were installed
*
Expand All @@ -295,6 +311,7 @@ namespace OgreBites
bool mFirstRun;
Ogre::String mNextRenderer; // name of renderer used for next run
Ogre::String mAppName;
Ogre::SceneManager *mSceneManager;

typedef std::vector<NativeWindowPair> WindowList;
WindowList mWindows; // all windows
Expand Down
17 changes: 17 additions & 0 deletions Components/Bites/src/OgreApplicationContextBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ void ApplicationContextBase::setup()

// adds context as listener to process context-level (above the sample level) events
mRoot->addFrameListener(this);

// add default scene manager
mSceneManager = createSceneManager();
}

void ApplicationContextBase::createRoot()
Expand Down Expand Up @@ -556,4 +559,18 @@ void ApplicationContextBase::pollEvents()
WindowEventUtilities::messagePump();
}

void ApplicationContextBase::mainLoop() {
OgreAssert(mRoot, "No root object created");
mRoot->startRendering();
}

Ogre::SceneManager *ApplicationContextBase::createSceneManager(Ogre::String type) {
OgreAssert(mRoot, "Root object not created");
return mRoot->createSceneManager(type);
}

Ogre::SceneManager *ApplicationContextBase::getSceneManager() {
return mSceneManager;
}

}
5 changes: 2 additions & 3 deletions Samples/Tutorials/Bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ int main(int argc, char *argv[])

//! [setup]
// get a pointer to the already created root
Ogre::Root* root = ctx.getRoot();
Ogre::SceneManager* scnMgr = root->createSceneManager();
auto scnMgr = ctx.getSceneManager();

// register our scene with the RTSS
Ogre::RTShader::ShaderGenerator* shadergen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
Expand Down Expand Up @@ -66,8 +65,8 @@ int main(int argc, char *argv[])
// register for input events
KeyHandler keyHandler;
ctx.addInputListener(&keyHandler);
ctx.mainLoop();

ctx.getRoot()->startRendering();
ctx.closeApp();
//! [main]
return 0;
Expand Down

0 comments on commit 9b7d88c

Please sign in to comment.