I have a problem which I describe below. I think that it is a Ogre 2.0 related issue so I hopefully this is in the correct spot.
Firstly, a disclaimer: I'm a rubbish programmer. I'm self taught and there is large gaps in my knowledge. I can usually work out my problems just by mucking around for days/weeks but this one has me beat - hopefully I'm not doing something stupid.
Back Ground Info
I have a framework that I have been using to create Ogre projects with for 4-5 years now. I occasionally modifiy it when I learn a new way of doing things. I decided I would convert my rendering system over to Ogre 2.0 and want to rewrite my object system from a component - object orientated design to a component - data orientated design. So I started a new project and stripped out everything everything except the Rendering system and the input system to make sure that I could get Ogre 2.0 to work and then rebuild the new game object system on top of that.
My Code
I used this code: https://gist.github.com/tahsmith/41d7f2e7d43be5ea1572 as a basis for my Ogre 2.0 initialisation. The key difference is that instead of
Code: Select all
Ogre::Root root("", "", "OgreLog.txt");
Code: Select all
m_pOgreRoot = new Ogre::Root("", "", "Ogre.log");
This is the code that I'm using:
Main.cpp
Code: Select all
Engine engine;
if( engine.Initialise() == true )
{
engine.ExecuteGameLoop();
}
Code: Select all
// These classes are singletons that I use so I can log messages anywhere and save/load settings anywhere in my code. I have been using them for a few years so I don't think the problem is in these classes.
[Logger class is initialised here]
[Settings class is initialised here]
// Initialise Render Manager
if( !m_bShutdownAndExit )
{
m_pRenderManager = new RenderManager();
if( !m_pRenderManager->Initialise() )
{
g_Logger->LogError( "ERROR: Failed to initialise the Render Manager." );
m_bShutdownAndExit = true;
}
}
// Initialise Input Manager
if( !m_bShutdownAndExit )
{
m_pInputManager = new InputManager();
if( !m_pInputManager->Initialise( m_pRenderManager->getOgreRenderWindow() ) )
{
g_Logger->LogError( "ERROR: Failed to initialise Input Manager." );
m_bShutdownAndExit = true;
}
}
RenderManager.cpp (Initialise Function)
Code: Select all
// Create root Ogre object
m_pOgreRoot = new Ogre::Root("", "", "Ogre.log");
// Load Plugins
Ogre::Root::getSingleton().loadPlugin( "./plugins/RenderSystem_Direct3D11");
Ogre::Root::getSingleton().loadPlugin( "./plugins/Plugin_ParticleFX");
Ogre::Root::getSingleton().loadPlugin( "./plugins/Plugin_CgProgramManager");
// Use the first available render system
Ogre::RenderSystem* renderSys = m_pOgreRoot->getAvailableRenderers()[0];
m_pOgreRoot->setRenderSystem(renderSys);
// Set video mode
renderSys->setConfigOption("Full Screen", "No");
renderSys->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
// Make the window
m_pRenderWindow = m_pOgreRoot->initialise(true);
// Start compositor
m_pOgreRoot->initialiseCompositor();
// Initialise resources for real-time shader
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/RTShaderLib", "FileSystem", "Essential");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/RTShaderLib/materials", "FileSystem", "Essential");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/RTShaderLib/hlsl", "FileSystem", "Essential");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/RTShaderLib/cg", "FileSystem", "Essential");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Essential");
// Initialise real-time shader
bool ok = Ogre::RTShader::ShaderGenerator::initialize();
auto &shaderGenerator = Ogre::RTShader::ShaderGenerator::getSingleton();
// Necessary for D3D11. It has no fixed function pipeline.
ShaderGeneratorTechniqueResolverListener sgtrl(&shaderGenerator);
Ogre::MaterialManager::getSingleton().addListener(&sgtrl);
// Initialise the scene manager
Ogre::SceneManager* m_pSceneManager = m_pOgreRoot->createSceneManager(Ogre::ST_GENERIC, 1, Ogre::INSTANCING_CULLING_SINGLETHREAD);
shaderGenerator.addSceneManager(m_pSceneManager);
// Load resource locations
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/models", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/programs", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/programs/cg", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/programs/hlsl", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
// Initialise camera & workspace
m_pCamera = m_pSceneManager->createCamera("Camera");
// Set up workspace
Ogre::CompositorManager2* pCompositorManager = m_pOgreRoot->getCompositorManager2();
const Ogre::String workspaceName = "scene workspace";
pCompositorManager->createBasicWorkspaceDef(workspaceName, Ogre::ColourValue::Black);
pCompositorManager->addWorkspace(m_pSceneManager, m_pRenderWindow, m_pCamera, workspaceName, true);
return true;
The Problem
Now, the problem. The render manager initialises fine and the code gets back to Engine.cpp Initialisation function and then hits the:
Code: Select all
// Initialise Input Manager
if( !m_bShutdownAndExit )
My Ogre log file if it is helpful: http://pastebin.com/6Rh3EsyU
The only thing of interest I can find in there is the "Compiler error: unknown error in RTShaderSystem.material(23): token "rtshader_system" is not recognized" line. I can make this go away by moving the RealTime Shader Generator initialisation code before the initialising of the real time shader resources, but I get the same memory corruption. I changed it back to match the code I originally copied from as I thought the author knew what he was doing more than I did.
I'm using the Ogre 2.0 code which I downloaded on the '30th of September, 2014'
I have compiled the sample browser and the Direct X 11 rendersystem and the sample browser does run correctly, though not all samples work.
I also wondered if my issue was covered in the Ogre 2.0 porting manual but I couldn't find it as dark_sylinc's website is down and it is hosted there? (BTW dark_sylinc, if you read this, is your website coming back?)
Thanks for any help and let me know if more info is needed.
Luke