Page 1 of 1

How to change imageset image dinmically.

Posted: Thu Mar 13, 2008 11:13
by HexDump
Hi all,

I´m trying to change the image of a StaticImage dynamically. The only way I have seen to do this is through a imageset. The imageset has a method defineImage where you insert an image in the set. Well, I have to change this image dynamically because it is a render to texture operation. I want to reuse the CEGUI::Texture and the CEGUI::Imageset for all operations, is this possible? I have this by now:

Code: Select all

   
        //Do next rtt operation
   RenderTexture* pTex=m_pSceneBurner->TakeShot();   
   //Texture regenarated
   CEGUI::Texture *cTex = pRenderer->createTexture((CEGUI::utf8*)"RttTex");
            
        //I previously created the  imageset this way
       
        static CEGUI::Imageset *imageSet = CEGUI::ImagesetManager::getSingleton().createImageset((CEGUI::utf8*)"RttImageset", cTex);
   imageSet->defineImage((CEGUI::utf8*)"RttImage",
      CEGUI::Point(0.0f, 0.0f),
      CEGUI::Size(cTex->getWidth(), cTex->getHeight()),
      CEGUI::Point(0.0f,0.0f));

        //So now I want to change dynamically the cTex data to reuse the texture I create before, and this way have the imageset first image change. What I´m trying to do is not recreate texture everytime and not recreate imageset. I want to reuse this ones.

   CEGUI::Window* pImage=*m_StaticImages.begin();
   pImage->setProperty("Image", CEGUI::PropertyHelper::imageToString(&imageSet->getImage((CEGUI::utf8*)"RttImage")));




Any help on this?

If anyone needs any more information let me know please.

HexDump.

Posted: Thu Mar 13, 2008 18:34
by scriptkid
To get this right, you are going to update 'cTex' and you want it to be visible on the image, right? If that's so, then IIRC updating cText from now on should do the trick. Since your ImageSet just has a pointer to it. Not a copy.

If you search for (but i think you already did) 'CreateTexture', you can find code alike yourse...

However i am not sure whether you are going to modify cTex in memory, or want to actually replace the Image with new files from disk. If that's so, you might look into the Texture's 'loadFromFile' method.

HTH.

Posted: Thu Mar 13, 2008 22:36
by HexDump
Thanks for the answer.

HexDump.