StaticImage - Loading/Setting background image

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

StaticImage - Loading/Setting background image

Postby Van » Fri Aug 19, 2005 11:01

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?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: StaticImage - Loading/Setting background image

Postby CrazyEddie » Fri Aug 19, 2005 13:39

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:

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.

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: StaticImage - Loading/Setting background image

Postby Van » Fri Aug 19, 2005 20:07

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?
Please stop automatically logging me out of the forums!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: StaticImage - Loading/Setting background image

Postby CrazyEddie » Sat Aug 20, 2005 18:09

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.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 12 guests