How to use CEGUI in Ogre which window is not create autoly?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

marty188586
Just popping in
Just popping in
Posts: 4
Joined: Sat Mar 02, 2013 02:11

How to use CEGUI in Ogre which window is not create autoly?

Postby marty188586 » Thu Aug 22, 2013 11:23

Hello,
I've met some issue while upgrading CEGUI from 0.7.5 to 0.8.2.
First of all. I'm using Ogre in a SDL window using the code from the following URL to get easy cross-platform IM (input method) support.
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=67570
and enable CEGUI by the code using the folling code from http://loremar.frihost.org/2011/12/using-cegui-in-ogre3d/

Code: Select all

//Initialize CEGUI
mRenderer = &CEGUI::OgreRenderer::bootstrapSystem();
 
//Set default resource groups for each CEGUI's resource manager
CEGUI::Imageset::setDefaultResourceGroup("Imagesets");
CEGUI::Font::setDefaultResourceGroup("Fonts");
CEGUI::Scheme::setDefaultResourceGroup("Schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
CEGUI::WindowManager::setDefaultResourceGroup("Layouts");
 
//Set the skin/scheme
CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
 
//Set default mouse cursor
CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");


this works perfectly with CEGUI 0.7.5, but whit some changes in 0.8.2 (function rename,etc......) it fails to work.

the first problem is that since my window in NOT created by Ogre but SDL. In CEGUI 0.8.2 CEGUI::OgreRenderer::bootstrapSystem() fails to return the correct value. and gave this info

Code: Select all

CEGUI::RendererException in function 'CEGUI::OgreRenderer::OgreRenderer()' (/home/marty/cegui-0.8.2/cegui/src/RendererModules/Ogre/Renderer.cpp:575) : Ogre was not initialised to automatically create a window, you should therefore be explicitly specifying a Ogre::RenderTarget in the OgreRenderer::create function.
terminate called after throwing an instance of 'CEGUI::RendererException'
  what():  CEGUI::RendererException in function 'CEGUI::OgreRenderer::OgreRenderer()' (/home/marty/cegui-0.8.2/cegui/src/RendererModules/Ogre/Renderer.cpp:575) : Ogre was not initialised to automatically create a window, you should therefore be explicitly specifying a Ogre::RenderTarget in the OgreRenderer::create function.

so I tried to go around it.

Code: Select all

Ogre::RenderTarget* renderTarget = root->getRenderTarget("MainRenderWindow");
CEGUI::OgreRenderer& myRenderer = CEGUI::OgreRenderer::create(*renderTarget);

However this couses program crashes(memory IO error)

What should I do to enable CEGUI in this condition?

Thanks for any help.

UPDATE: Fix spelling error

marty188586
Just popping in
Just popping in
Posts: 4
Joined: Sat Mar 02, 2013 02:11

Re: How to use CEGUI in Ogre which window is not create auto

Postby marty188586 » Tue Aug 27, 2013 08:31

Well, I found a way to fix it

Code: Select all

//Initialize CEGUI
   Ogre::RenderTarget* renderTarget = root->getRenderTarget("MainRenderWindow");
   CEGUI::OgreRenderer& myRenderer = CEGUI::OgreRenderer::bootstrapSystem(*renderTarget);

   //window manager
   CEGUI::WindowManager& winMgr(CEGUI::WindowManager::getSingleton());

   //setup CEGUI resorus
   CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
   CEGUI::GUIContext& guiContext = CEGUI::System::getSingleton().createGUIContext(myRenderer.getDefaultRenderTarget());
   guiContext.getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
   CEGUI::Window *guiRoot = winMgr.createWindow("DefaultWindow", "root");
   guiContext.setRootWindow(guiRoot);


this is how to use CEGUI in Ogre + SDL.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests