Creates Imagesets "on the fly" ... and destroy them?

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

matt
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Tue Nov 08, 2011 16:00

Creates Imagesets "on the fly" ... and destroy them?

Postby matt » Wed Apr 04, 2012 11:57

Hello!

I need to creates some buttons "on the fly", and these buttons display images that are stored in a folder of my project.
I can't use some ".imageset" file, because it's totally dynamic.

So the solution I've found is to create an imageset, define an image that is 100%*100% of this imageset, and bind this image to my widget.
Is it the fastiest way to acheive it?

I do like that:

Code: Select all

      CustomButton* button = static_cast<CustomButton*>(wmgr.createWindow( "MyWidgets/CustomButton" ));

      try
      {
         std::string imageSetName(button->getName().c_str());  //Define a unique imageSet using the unique name of the button given my the WindowManager
         std::string imageURL(button->getIdStr().c_str());     //This custom property is my Image URL
         //Creates an imageset, and a 100%*100% image
         CEGUI::Imageset& imageSet = CEGUI::ImagesetManager::getSingleton().createFromImageFile(imageSetName,imageURL,"");   
         imageSet.defineImage("fullimage", Point(0.0f,0.0f), imageSet.getNativeResolution(), Point(0.0f,0.0f));
         //Bind the image the widget
         button->setProperty("NormalImage", String("set:")+ imageSetName +" image:fullimage");
      }
      catch( CEGUI::FileIOException &e )
      {      
         CEGUI::Logger::getSingleton().logEvent(e.getFullDescription() + " : " + e.getFile());
         //Use a common image, is the URL of the image is wrong
         item->setProperty( "NormalImage", "set:MyIcons image:dummyImage" );    
      }   


But I regularly need to destroy my widgets, and I don't know if the ImageSets that are bound to are also destroyed ?
Do I need to manage Imageset destruction, to remove the textures from the memory?

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

Re: Creates Imagesets "on the fly" ... and destroy them?

Postby Kulik » Wed Apr 04, 2012 21:08

In 0.7 creating Imagesets with full rectangle images on them is the only way unfortunately.

You have to destroy the imagesets after use, they are not garbage collected automatically.

matt
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Tue Nov 08, 2011 16:00

Re: Creates Imagesets "on the fly" ... and destroy them?

Postby matt » Thu Apr 05, 2012 14:00

Thanx Kulik for this short and explicit answer! :)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests