My goal is rendering CEGUI into Ogre::Texture.
Before CEGUI Ogre was precompiled by. Now I try with CEGUI 0.7.1.
With CEGUI 0.7.1 my GUI rendering is OFF.
For init GUI system, my code was like this :
Code: Select all
void Ca::Gui::Manager::CreateGuiSystem()
{
if( !m_InitGui )
{
m_InitGui = true ;
m_GuiSceneManager = Ogre::Root::getSingleton().createSceneManager( Ogre::ST_GENERIC, "GuiManager" ) ;
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps( 5 ) ;
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups() ; // All compistor are loaded
m_GuiTexture = Ogre::TextureManager::getSingleton().createManual( "GuiText", "Gui", Ogre::TEX_TYPE_2D, 2048, 512, 1, 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET ) ;
m_GuiRenderTarget = m_GuiTexture->getBuffer()->getRenderTarget() ;
m_GuiCamera = m_GuiSceneManager->createCamera( "GuiCam" ) ;
m_GuiCamera->setPosition( Ogre::Vector3::ZERO ) ;
m_GuiCamera->lookAt( Ogre::Vector3( 0, 0, -300 ) ) ;
m_GuiCamera->setNearClipDistance( 5 ) ;
m_GuiViewport = m_GuiRenderTarget->addViewport( m_GuiCamera ) ;
m_GuiViewport->setBackgroundColour( Ogre::ColourValue::Black ) ;
m_GUIRenderer = new CEGUI::OgreCEGUIRenderer( m_GuiRenderTarget, Ogre::RENDER_QUEUE_OVERLAY, true, 0, m_GuiSceneManager ) ;
m_GUISystem = new CEGUI::System( m_GUIRenderer, NULL, NULL, NULL, "", "../../Log/CEGUI.log" ) ;
CEGUI::Logger::getSingleton().setLoggingLevel( CEGUI::Informative ) ;
// Retrieve CEGUI texture for the RTT
CEGUI::OgreCEGUITexture* aRttTexture = static_cast<CEGUI::OgreCEGUITexture*>( m_GUIRenderer->createTexture( m_GuiTexture ) ) ;
CEGUI::Imageset* aRttImageSet = CEGUI::ImagesetManager::getSingleton().createImageset( (CEGUI::utf8*)"RttImageset", aRttTexture ) ;
aRttImageSet->defineImage( (CEGUI::utf8*)"RttImage", CEGUI::Point( 0, 0 ), CEGUI::Size( aRttTexture->getWidth(), aRttTexture->getHeight() ), CEGUI::Point( 0, 0 ) ) ;
CEGUI::SchemeManager::getSingleton().loadScheme( (CEGUI::utf8*)"AquaLookSkin.scheme" ) ;
CEGUI::SchemeManager::getSingleton().loadScheme( (CEGUI::utf8*)"TaharezLook.scheme" ) ;
CEGUI::SchemeManager::getSingleton().loadScheme( (CEGUI::utf8*)"VanillaSkin.scheme" ) ;
CEGUI::SchemeManager::getSingleton().loadScheme( (CEGUI::utf8*)"WindowsLook.scheme" ) ;
m_GUISystem->setDefaultMouseCursor( (CEGUI::utf8*)"AquaLook", (CEGUI::utf8*)"MouseArrow" ) ;
m_GUISystem->setMouseMoveScaling( 1 ) ;
m_GUISystem->setDefaultFont( (CEGUI::utf8*)"BlueHighway-12" ) ;
Ogre::CompositorManager::getSingleton().addCompositor( m_GuiViewport, "Comp/GuiAlpha" ) ;
Ogre::CompositorManager::getSingleton().setCompositorEnabled( m_GuiViewport, "Comp/GuiAlpha", true ) ;
}
}
Now it's :
Code: Select all
void Ca::Gui::Manager::CreateGuiSystem()
{
if( !m_InitGui )
{
m_InitGui = true ;
m_GuiSceneManager = Ogre::Root::getSingleton().createSceneManager( Ogre::ST_GENERIC, "GuiManager" ) ;
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps( 5 ) ;
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups() ; // All compositor are loaded
m_GuiTexture = Ogre::TextureManager::getSingleton().createManual( "GuiText", "Gui", Ogre::TEX_TYPE_2D, 2048, 512, 1, 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET ) ;
m_GuiRenderTarget = m_GuiTexture->getBuffer()->getRenderTarget() ;
m_GuiCamera = m_GuiSceneManager->createCamera( "GuiCam" ) ;
m_GuiCamera->setPosition( Ogre::Vector3::ZERO ) ;
m_GuiCamera->lookAt( Ogre::Vector3( 0, 0, -300 ) ) ;
m_GuiCamera->setNearClipDistance( 5 ) ;
m_GuiViewport = m_GuiRenderTarget->addViewport( m_GuiCamera ) ;
m_GuiViewport->setBackgroundColour( Ogre::ColourValue::Black ) ;
CEGUI::String aConfigFile( "" ),
aLogFile( "../../Log/CEGUI.log" ) ;
CEGUI::DefaultLogger &aLogger = *new CEGUI::DefaultLogger() ;
aLogger.setLogFilename( aLogFile, false ) ;
aLogger.setLoggingLevel( CEGUI::Informative ) ;
CEGUI::OgreRenderer &aGUIRenderer = CEGUI::OgreRenderer::bootstrapSystem( *m_GuiRenderTarget ) ;
// Retrieve CEGUI texture for the RTT
CEGUI::Texture &aRttTexture = aGUIRenderer.createTexture( m_GuiTexture ) ;
CEGUI::Imageset &aRttImageSet = CEGUI::ImagesetManager::getSingleton().create( (CEGUI::utf8*)"RttImageset", aRttTexture ) ;
aRttImageSet.defineImage( (CEGUI::utf8*)"RttImage", CEGUI::Point( 0, 0 ), aRttTexture.getSize(), CEGUI::Point( 0, 0 ) ) ;
CEGUI::SchemeManager::getSingleton().create( (CEGUI::utf8*)"AquaLookSkin.scheme" ) ;
CEGUI::SchemeManager::getSingleton().create( (CEGUI::utf8*)"TaharezLook.scheme" ) ;
CEGUI::SchemeManager::getSingleton().create( (CEGUI::utf8*)"VanillaSkin.scheme" ) ;
CEGUI::SchemeManager::getSingleton().create( (CEGUI::utf8*)"WindowsLook.scheme" ) ;
CEGUI::System &aGuiSystem = CEGUI::System::getSingleton() ;
aGuiSystem.setDefaultMouseCursor( (CEGUI::utf8*)"AquaLook", (CEGUI::utf8*)"MouseArrow" ) ;
aGuiSystem.setMouseMoveScaling( 1 ) ;
aGuiSystem.setDefaultFont( (CEGUI::utf8*)"BlueHighway-12" ) ;
Ogre::CompositorManager::getSingleton().addCompositor( m_GuiViewport, "Comp/GuiAlpha" ) ;
Ogre::CompositorManager::getSingleton().setCompositorEnabled( m_GuiViewport, "Comp/GuiAlpha", true ) ;
}
}
Fore create Window is always that :
Code: Select all
m_MainMenu = CEGUI::WindowManager::getSingleton().loadWindowLayout( (CEGUI::utf8*)"Menu.layout", m_PrefixNameWindow ) ;
CEGUI::System::getSingleton().setGUISheet( m_MainMenu ) ;
Link :
http://www.cegui.org.uk/wiki/index.php/Main_Page
http://www.cegui.org.uk/docs/current/porting6to7.html
http://www.cegui.org.uk/docs/current/re ... orial.html
Remarks :
For delete GUI system :
Before :
Code: Select all
if( m_InitGui )
{
CEGUI::WindowManager::getSingleton().destroyAllWindows() ;
CEGUI::WindowManager::getSingleton().cleanDeadPool() ;
m_GuiTexture.setNull() ;
if( m_GUISystem )
{
delete m_GUISystem ;
m_GUISystem = NULL ;
}
if( m_GUIRenderer )
{
delete m_GUIRenderer ;
m_GUIRenderer = NULL ;
}
m_InitGui = false ;
}
Now :
Code: Select all
if( m_InitGui )
{
CEGUI::SchemeManager::getSingleton().destroyAll() ;
CEGUI::WindowManager::getSingleton().destroyAllWindows() ;
CEGUI::WindowManager::getSingleton().cleanDeadPool() ;
m_GuiTexture.setNull() ;
// Not very pretty...
CEGUI::OgreRenderer *aGUIRenderer = static_cast<CEGUI::OgreRenderer*>( CEGUI::System::getSingleton().getRenderer() ) ;
CEGUI::System::destroy() ;
CEGUI::OgreRenderer::destroy( *aGUIRenderer ) ;
m_InitGui = false ;
}