Simple static image - surely anyone could help!?
Posted: Fri May 06, 2005 13:55
by TheGilb
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!

Re: Simple static image - surely anyone could help!?
Posted: Fri May 06, 2005 19:35
by TheGilb
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!
Re: Simple static image - surely anyone could help!?
Posted: Wed May 11, 2005 01:07
by gcarlton
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!
