Well, I have the same problem..
First I used some code I hacked together pretty quickly - everything ran fine. I then started splitting the code up, not unlike the gamestate-tutorial does it.
That's when the errors started - namely thrown by the ResourceGroupManager and the InputReader.
Since those functions are closely related to the only "Singleton"-like stuff I built in yet, I guess that's causing the error.
I wasn't able to build that Singleton-Feature into my class as well - I am still learning some aspects of C++/etc. - so I guess it's theoretically possible to have TWO ResourceGroupManagers. Not that I do - but I could have, by creating two instances of the "game"-class that I created and where I encapsuled the Ogre-Stuff.
Creating the InputReader as well as adding ResourceDirs doesn't cause any problems, but capturing the input as well as initialising the directories does.
I didn't have any of those problems when all my stuff was still in one big function (the main-one). I guess you did not ever get that error because you never tried putting ResourceManagers or something similir inside of classes that might be instanced more than once?
Setting that "multi threaded DLL"-option wouldn't do me any good, since it had been activated from start (used that wizard). That includes Release-mode.
Some code in case I didn't manage to make myself clear above..
Code: Select all
// taken from header.h
class Game
{
public:
Game();
~Game();
void start();
void setupResFolders();
void mainLoop();
protected:
float timeSinceLast;
Ogre::Root* mRoot;
Ogre::RenderWindow* mWindow;
Ogre::SceneManager* mSceneMgr;
Ogre::Viewport* mViewport;
Ogre::InputReader* mInputReader;
// taken from game.cpp
void Game::setupResFolders()
{
Ogre::ConfigFile mConfigFile;
mConfigFile.load("resources.cfg");
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator mSectionIterator = mConfigFile.getSectionIterator();
Ogre::String secName, typeName, archName;
while (mSectionIterator.hasMoreElements())
{
secName = mSectionIterator.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *mSettingsMultiMap = mSectionIterator.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator mIterator;
for (mIterator = mSettingsMultiMap->begin(); mIterator != mSettingsMultiMap->end(); ++mIterator)
{
typeName = mIterator->first;
archName = mIterator->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
} // of for
} // of while
// Initialise all Resource-Folders
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); // crashes right here
}
Commenting out the ResourceGroupManager-initialise-thingie, the second crash is caused by...
Code: Select all
// taken from game.cpp, void game::start()
// Set up Window
RenderWindow* mRenderWindow;
mRenderWindow = mRoot->initialise(true,"Awesome Game");
// create and choose Scene-Manager
SceneManager* mSceneMgr;
mSceneMgr = mRoot->createSceneManager(ST_GENERIC);
// create InputReader
InputReader* mInputReader = PlatformManager::getSingleton().createInputReader();
mInputReader->initialise(mRenderWindow);
//start mainLoop
mainLoop();
//
// somewhat further down in game.cpp ...
void Game::mainLoop()
{
// mainLoop here
while (true)
{
timeSinceLast = UpdateTime();
//run = 1;
mInputReader->capture(); // crashes right here
Please try to overlook any serious insults to OO-programming that I might have done