Simple static image - surely anyone could help!?

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
TheGilb
Just popping in
Just popping in
Posts: 4
Joined: Fri Jan 28, 2005 11:17

Simple static image - surely anyone could help!?

Postby TheGilb » Fri May 06, 2005 13:55

Ok I've gotten this far, I've got a really nice GUI in the works for a simple editing application I'm writing using OGRE, CEGUI and a pinch of magic.

However I have come to a resounding halt! I want to have a simple, simple static image at the top of my screen! Something like a title image if you get me.

So if the image is called title.tga, is 1024 x 90, and I want it to go in a StaticImage widget called "Application/Titlebar/TitleImage". How do it make it happen?!?

Please make your code / references / xml as clear and concise as possible, my brain is feeble and weak. Even the imbecile's tutorials on the wiki couldn't help! :shock:

User avatar
TheGilb
Just popping in
Just popping in
Posts: 4
Joined: Fri Jan 28, 2005 11:17

Re: Simple static image - surely anyone could help!?

Postby TheGilb » Fri May 06, 2005 19:35

Ok peeps, I got bored of waiting for a response (I know, I know, I'm really impatient!) so I went right ahead and found out how to do it myself, and it's great because now my program looks more professional ;)

I'm actually here to document exactly how you do this. Perhaps someone will migrate this post to the wiki some day?... I know I rely on wiki's and forums for a lot of my information these days. Someone will appreciate this some day!

First set up your xml file (You're already working on your GUI at this stage!) with the following lines of code:
<Window Type="TaharezLook/StaticImage" Name="Application/Titlebar/TitleImage">
<Property Name="Alpha" Value="0.750000" />
<Property Name="RelativeRect" Value="l:0.000000 t:0.000000 r:1 b:1" />
</Window>

That is, you create a StaticImage in your GUI. This is step 1, and probably the most obvious. Now you jump into C++ and right after your CEGUI init (You've already got this far!):
/* Create CEGUI texture (file must be in resource dir) */
CEGUI::Texture* mtitletex = mGUIRenderer->createTexture("orbapptitle.tga");
/* Get handle to CEGUI widget */
CEGUI::StaticImage* mtitlestatic = (CEGUI::StaticImage*)CEGUI::WindowManager::getSingleton().getWindow("Application/Titlebar/TitleImage");

/* Create an imageset called RttImageset */
CEGUI::Imageset* rttImageSet = CEGUI::ImagesetManager::getSingleton().createImageset((CEGUI::utf8*)"RttImageset",mtitletex);

/* Define a single image in the set which fills it */
rttImageSet->defineImage((CEGUI::utf8*)"ORBAppTitleImage",
CEGUI::Point(0.0f, 0.0f),
CEGUI::Size(mtitletex->getWidth(), mtitletex->getHeight()),
CEGUI::Point(0.0f,0.0f));

/* Now set the image property of the CEGUI widget and you're done! */
mtitlestatic->setImage("RttImageset", "ORBAppTitleImage");

And that's it! References include CEGUI API Reference and Ogre GUI demo. Thanks!

User avatar
gcarlton
Just can't stay away
Just can't stay away
Posts: 149
Joined: Wed Jan 12, 2005 12:06

Re: Simple static image - surely anyone could help!?

Postby gcarlton » Wed May 11, 2005 01:07

That style of loading is good for any dynamic situation, for example loading thumbnail images, etc.

For purely static images, it may be better to combine them into a single texture and then create an xml imageset file that references them.

But whatever gets it working really! :)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 8 guests