Would someone please explain to me clearly how one goes about setting the background image of a window?
We have a StaticImage window with widgets. The goal is to change the StaticImage window background based on some criteria. I want to load the image from a file (like a png or jpg for example). What are the steps needed to accomplish this?
StaticImage - Loading/Setting background image
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: StaticImage - Loading/Setting background image
The first thing you need in order to do this is an Imageset that defines the Image that you wish to use. When wanting to use an image file for this as you suggest, you basically have an imageset defined like this:
What this does is define an Imageset using the backdrop.tga. A single image "Backdrop" is defined that starts at location (0,0) and is 1024 x 768 in size. You should be careful in that the source image file should have dimensions that are powers of two - this is because the image is loaded as a texture, and may be stretched if the powers-of-two requirement is not observed.
Once you have your imageset defined, you can load it either by adding a reference to it in whichever scheme you are loading, or manually using the ImagesetManager:
Once the thing is loaded, you set the image into the StaticImage like so:
Notice that the names we specify here are the ones that were originally specified in the imageset XML file.
There are other ways of going about this, you can create the whole lot dynamically in code, though you have to provide a pre-loaded image as a texture - so the above is probably the easiest way at the moment.
In 0.4.0 there will be support for creating Imagesets directly from images (in fact I added in CVS earlier today).
HTH
CE.
Code: Select all
<?xml version="1.0" ?>
<Imageset Name="BackdropImageset" Imagefile="backdrop.tga" NativeHorzRes="1024" NativeVertRes="768" AutoScaled="true">
<Image Name="Backdrop" XPos="0" YPos="0" Width="1024" Height="768" />
</Imageset>
What this does is define an Imageset using the backdrop.tga. A single image "Backdrop" is defined that starts at location (0,0) and is 1024 x 768 in size. You should be careful in that the source image file should have dimensions that are powers of two - this is because the image is loaded as a texture, and may be stretched if the powers-of-two requirement is not observed.
Once you have your imageset defined, you can load it either by adding a reference to it in whichever scheme you are loading, or manually using the ImagesetManager:
Code: Select all
CEGUI::ImagesetManager::getSingleton().createImageset("myImageset.imagset");
Once the thing is loaded, you set the image into the StaticImage like so:
Code: Select all
myStaticImage->setImage("BackdropImageset", "Backdrop");
Notice that the names we specify here are the ones that were originally specified in the imageset XML file.
There are other ways of going about this, you can create the whole lot dynamically in code, though you have to provide a pre-loaded image as a texture - so the above is probably the easiest way at the moment.
In 0.4.0 there will be support for creating Imagesets directly from images (in fact I added in CVS earlier today).
HTH
CE.
Re: StaticImage - Loading/Setting background image
Thanks Boss...
BTW, does the image have to be static as the widget name implies? That is could you use something like an animated gif?
BTW, does the image have to be static as the widget name implies? That is could you use something like an animated gif?
Please stop automatically logging me out of the forums!
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: StaticImage - Loading/Setting background image
Currently it needs to be static. CEGUI has no integrated animation support at the moment.
If you want animation, you'd need to collect all the animation frames together and build a more complex imageset XML file, then you'd need some code in the app to control the animation yourself.
If you want animation, you'd need to collect all the animation frames together and build a more complex imageset XML file, then you'd need some code in the app to control the animation yourself.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 12 guests