My code to create windows and initialize CEGUI looks like this:
Code: Select all
Ogre::RenderWindow *window = root->createRenderWindow("Awesome window", 800, 600, false);
Ogre::RenderWindow *window2 = root->createRenderWindow("Awesome window 2!", 800, 600, false);
Ogre::SceneManager* sceneManager = root->createSceneManager(Ogre::ST_EXTERIOR_CLOSE, /*"DefaultSceneManager", */8, Ogre::INSTANCING_CULLING_THREADED);
Ogre::SceneManager* sceneManager2 = root->createSceneManager(Ogre::ST_EXTERIOR_CLOSE, /*"DefaultSceneManager", */8, Ogre::INSTANCING_CULLING_THREADED);
Ogre::CompositorManager2 *compositorManager = root->getCompositorManager2();
const Ogre::IdString workspaceName("Awesome workspace1");
compositorManager->createBasicWorkspaceDef( workspaceName, Ogre::ColourValue(0.5f, 0.5f, 0.5f, 0.5f), Ogre::IdString());
compositorManager->addWorkspace( sceneManager, window, camera, workspaceName, true );
Ogre::Viewport* viewport = window->getViewport(0);
camera->setAspectRatio(Ogre::Real(viewport->getActualWidth()) / Ogre::Real(viewport->getActualHeight()));
/*const Ogre::IdString workspaceName2("Awesome workspace2");
compositorManager->createBasicWorkspaceDef( workspaceName2, Ogre::ColourValue(0.5f, 0.5f, 0.5f, 0.5f), Ogre::IdString());
compositorManager->addWorkspace( sceneManager2, window2, camera2, workspaceName2, true );
Ogre::Viewport* viewport2 = window2->getViewport(0);
camera2->setAspectRatio(Ogre::Real(viewport2->getActualWidth()) / Ogre::Real(viewport2->getActualHeight()));*/
ceguiOgreRenderer = &CEGUI::OgreRenderer::create(*window);
ceguiOgreRenderer->setDefaultRootRenderTarget(*window);
&CEGUI::System::create(*ceguiOgreRenderer, new CEGUI::OgreResourceProvider(), 0, new CEGUI::OgreImageCodec());
/*setting up CEGUI resources*/
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::Window *sheet = wmgr.createWindow("DefaultWindow");
CEGUI::RenderTarget *target = new CEGUI::OgreWindowTarget(*ceguiOgreRenderer, *root->getRenderSystem(), *window);
CEGUI::GUIContext *guiContext = &CEGUI::System::getSingleton().createGUIContext(*target);
//CEGUI::GUIContext *guiContext = &CEGUI::System::getSingleton().getDefaultGUIContext();
guiContext->setRootWindow(sheet);
frameListener->setGuiContext(guiContext);
root->addFrameListener(frameListener);
ceguiOgreRenderer->setRenderingEnabled(false);
Now frame listener's code:
Code: Select all
CEGUI::System& gui_system(CEGUI::System::getSingleton());
float dt = 1e-2f;
gui_system.injectTimePulse(dt);
//d_sampleApp->update(static_cast<float>(elapsed));
//beginRendering(elapsed);
CEGUI::Renderer* gui_renderer(gui_system.getRenderer());
gui_renderer->beginRendering();
//d_sampleApp->renderGUIContexts();
guiContext->injectTimePulse(1e-2f);
guiContext->draw();
gui_renderer->endRendering();
CEGUI::WindowManager::getSingleton().cleanDeadPool();
This code creates 2 windows and attaches CEGUI context to the first one. It works fine: there's 2 ogre windows and CEGUI button inside the first one.
However, if I uncomment commented code that creates a workspace for the second window, CEGUI in the first one gets borked: I get white rectangles instead of symbols in the fonts.
And if I init CEGUI for the second window as well, it renders perfectly well while the first window remains borked:
Here's full code of my problematic code(with syntax highligting for easier reading): http://pastebin.com/mTvUSuMZ
It's a double-post from ogre's forums http://www.ogre3d.org/forums/viewtopic.php?f=25&t=82696 but no one managed to help me with this one. Hopefully you guys can help.