Manually updating a render surface

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

cloud
Just popping in
Just popping in
Posts: 2
Joined: Fri Sep 24, 2010 09:05

Manually updating a render surface

Postby cloud » Fri Sep 24, 2010 09:12

Hi there.

So what I'm trying to do is render a static text box to render target and then display the text in 3d space, my code is

Code: Select all

        CEGUI::WindowManager* winMgr = CEGUI::WindowManager::getSingletonPtr();
        CEGUI::Window* win = winMgr->createWindow(
            InterfaceCEGUI::PRIMARY_GUI_NAME + "/StaticText", "Test00000");
        win->setText("Simple Test");
        win->setSize(CEGUI::UVector2(CEGUI::UDim(0.2,0), CEGUI::UDim(0.2, 0)));
        win->setPosition(CEGUI::UVector2(CEGUI::UDim(0.4, 0), CEGUI::UDim(0.4, 0)));
        win->setUsingAutoRenderingSurface(true);
        //CEGUI::System::getSingleton().getGUISheet()->addChildWindow(win);
       
        CEGUI::OgreTextureTarget& target = dynamic_cast<CEGUI::OgreTextureTarget&>(win->getRenderingSurface()->getRenderTarget());
        CEGUI::Texture& baseTexture = target.getTexture();       
        CEGUI::OgreTexture& texture = dynamic_cast<CEGUI::OgreTexture&>(baseTexture);
       
       
        Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName("CEGUI/RenderSurface");
        Ogre::Pass *pass = mat->getTechnique(0)->getPass(0);
        pass->getTextureUnitState(0)->setTextureName( texture.getOgreTexture()->getName() );
       
        BillboardSet* bbs = mSceneMgr->createBillboardSet(1);
        bbs->setMaterialName(mat->getName());
        bbs->setDefaultWidth(3);
        bbs->setDefaultHeight(2);
        bbs->createBillboard(Vector3(0, 2, 0));
        mSceneMgr->getRootSceneNode()->attachObject(bbs);


uncommenting the CEGUI::System::getSingleton().getGUISheet()->addChildWindow(win);

will cause the window to update but then obviuoly I get it in the sheet as well... and presumably I'd be rendering it every fame, both of which are really not what I want.

Any help for a nub?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Manually updating a render surface

Postby Kulik » Fri Sep 24, 2010 11:38

Easiest would be to wait for 0.8 where multi root will (most likely) be supported.

Hardest (and GREATEST!!!) would be to develop it and publish the patch.

Meanwhile you can get around this by having a window with auto render surface, not adding it anywhere and manually calling update and draw on it (I somehow got this working, I will post the details there when I get my dev environment working).

In the end I settled for a different solution. I don't display text in 3D anymore, I simply project 3D coords onto 2D plane and overlay text over the existing viewport, It's much more usable and easier to implement.


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 11 guests