I've been using CEGUI with Ogre 1.9 for some time, then I decided to upgrade to Ogre 2.1 and the API to set up CEGUI changed. I have found somewhere how to to get it working, it allowed me to compile the program but I could not test it right afterwards. When I finally could test it, I realised that CEGUI is completely invisible. Now I can't find the tutorial how to get it running. I have searched the Internet, but I found almost nothing.
The best thing I could find was this liked from this thread. This also gave out a bit of information.
I can't find any proper information how to set it up, so I would be really happy if someone assisted me in fixing the issue because it seems I can't do it alone.
Here is the code that sets up Ogre and CEGUI:
Code: Select all
root_ = std::unique_ptr<Ogre::Root>(new Ogre::Root());
root_->loadPlugin(prefs.renderSystem);
root_->loadPlugin("Plugin_ParticleFX");
const Ogre::RenderSystemList& renderSystems = root_->getAvailableRenderers();
if (renderSystems.empty()) throw(std::runtime_error("Cannot find the desired render system"));
root_->setRenderSystem(renderSystems[0]);
root_->initialise(false, "Render Window", "");
// SDL2 is initialised here and Ogre is configured to use its window, but it appears to work and it was copied from an Ogre sample anyway
Ogre::NameValuePairList params;
params["FSAA"] = std::to_string(prefs.FSAA);
params["vsync"] = prefs.vsync ? "true" : "false";
renderWindow_ = root_->createRenderWindow("Render Window", prefs.displayWidth, prefs.displayHeight, prefs.fullscreen, ¶ms);
sceneManager_ = root_->createSceneManager(Ogre::ST_GENERIC, 3, Ogre::INSTANCING_CULLING_THREADED, "GameSceneMgr");
sceneManager_->setForward3D(true, 4, 4, 5, 96, 3, 200);
sceneManager_->setShadowFarDistance(prefs.shadowFarDistance);
camera_ = sceneManager_->createCamera("GameCamera");
compositorManager_ = root_->getCompositorManager2();
const Ogre::IdString workspaceName("Main Workspace");
if (!compositorManager_->hasWorkspaceDefinition(workspaceName)) {
compositorManager_->createBasicWorkspaceDef(workspaceName, Ogre::ColourValue(0.5f, 0.5f, 0.5f), Ogre::IdString());
}
compositorManager_->addWorkspace(sceneManager_, renderWindow_, camera_, workspaceName, true);
guiRenderer_ = &CEGUI::OgreRenderer::bootstrapSystem(*renderWindow_);
std::cout << "CEGUI verification " << CEGUI::System::getSingleton().getDefaultGUIContext().isRenderingWindow()
<< " " << guiRenderer_->isRenderingEnabled() << std::endl;
At this point, I am informed that the default GUI context isn't a rendering window.
Afterwards, I set up CEGUI to actually show an intro scren, I don't think there is an error there but I am posting it for completeness' sake:
Code: Select all
// This part is probably irrelevant
guiRenderer_ = renderer;
Ogre::ResourceGroupManager& resManager = Ogre::ResourceGroupManager::getSingleton();
resManager.addResourceLocation("media/cegui/imagesets", "FileSystem", "Imagesets");
resManager.addResourceLocation("media/cegui/fonts", "FileSystem", "Fonts");
resManager.addResourceLocation("media/cegui/layouts", "FileSystem", "Layouts");
resManager.addResourceLocation("media/cegui/looknfeel", "FileSystem", "LookNFeel");
resManager.addResourceLocation("media/cegui/schemes", "FileSystem", "Schemes");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
CEGUI::ImageManager::setImagesetDefaultResourceGroup("Imagesets");
CEGUI::Font::setDefaultResourceGroup("Fonts");
CEGUI::Scheme::setDefaultResourceGroup("Schemes");
CEGUI::SchemeManager::getSingleton().createFromFile("Generic.scheme");
CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
CEGUI::WindowManager::setDefaultResourceGroup("Layouts");
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
sheet_ = wmgr.createWindow("DefaultWindow", "CEGUIDemo/Sheet");
CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(sheet_);
CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->setProperty(CEGUI::String("AutoRenderingSurface"), CEGUI::String("false"));
std::cout << "CEGUI verification " << CEGUI::System::getSingleton().getDefaultGUIContext().isRenderingWindow()
<< " " << guiRenderer_->isRenderingEnabled() << std::endl;
// Still not a rendering window
CEGUI::ImageManager::getSingleton().loadImageset("title.imageset", "Imagesets");
// THIS PART SHOULD BE RELEVANT
loadingScreen_ = wmgr.createWindow("Generic/Image","loadingScreen");
loadingScreen_->setSize(CEGUI::USize(cegui_reldim(1.0f), cegui_reldim(1.0f)));
loadingScreen_->setProperty("Image", "title/title");
loadingScreen_->setMousePassThroughEnabled(false);
loadingScreen_->setRiseOnClickEnabled(false);
loadingScreen_->setProperty(CEGUI::String("AutoRenderingSurface"), CEGUI::String("false")); // I've found somewhere that this might be necessary, doesn't seem to help, though
sheet_->addChild(loadingScreen_);
With every frame, I run:
Code: Select all
root_->renderOneFrame();
CEGUI::System::getSingleton().injectTimePulse(period);
CEGUI::System& guiSystem = CEGUI::System::getSingleton();
guiSystem.injectTimePulse(period);
CEGUI::Renderer* guiRenderer(guiSystem.getRenderer());
guiRenderer->beginRendering();
guiSystem.getDefaultGUIContext().injectTimePulse(period / 1000);
guiSystem.getDefaultGUIContext().draw();
guiRenderer->endRendering();
CEGUI::WindowManager::getSingleton().cleanDeadPool();
Ogre itself is running properly and I see what it renders. No CEGUI window shows up ever, no error messages appear neither.