Page 1 of 1

Manually updating a render surface

Posted: Fri Sep 24, 2010 09:12
by cloud
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?

Re: Manually updating a render surface

Posted: Fri Sep 24, 2010 11:38
by Kulik
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.