Question Using Static Images - Noobie

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
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Wed Apr 06, 2005 08:25

Question Using Static Images - Noobie

Postby kungfoomasta » Mon Apr 11, 2005 20:04

I got a window up and can use buttons, but I can't seem to put in a static image. Can anybody provide a simple example to put a static image in a window? I reused code from the demo_gui, but it doesn't show up.

The code looks like:

CEGUI::Imageset* imageSet = CEGUI::ImagesetManager::getSingleton().getImageset( "TaharezLook" );

CEGUI::StaticImage* si = (CEGUI::StaticImage*)CEGUI::WindowManager::getSingleton().createWindow( "Taharez/StaticImage", "NewStaticImage1" );
si->setSize(CEGUI::Size(0.2f, 0.2f));
si->setImage(&imageSet->getImage( "ClientBrush" ));

Also, how do I go about using my own images? What file format do they have to be, and how do I create them in an imageset? I read Clay's post, but it's in XML.


User avatar
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Question Using Static Images - Noobie

Postby lindquist » Tue Apr 12, 2005 22:25

Code: Select all

CEGUI::StaticImage* si = (CEGUI::StaticImage*)CEGUI::WindowManager::getSingleton().createWindow( "TaharezLook/StaticImage", "NewStaticImage1" );

User avatar
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Wed Apr 06, 2005 08:25

Re: Question Using Static Images - Noobie

Postby kungfoomasta » Thu Apr 14, 2005 05:04

I have 4 different images:

And I want to use just one of these on my GUI.

My sheet is set up as follows:
wm = &(CEGUI::WindowManager::getSingleton());

// create gui sheet
CEGUI::Window *sheet = wm->createWindow( "DefaultGUISheet", "root" );
CEGUI::System::getSingleton().setGUISheet( sheet );

My window is set up as follows:
// create framewindow
CEGUI::FrameWindow *fw = (CEGUI::FrameWindow *)wm->createWindow( "TaharezLook/FrameWindow", "mainWindow" );
sheet->addChildWindow( fw );

Now I want to use the static image, so that I can see it on the page. What I have right now (it doesn't work):
CEGUI::StaticImage* si = (CEGUI::StaticImage*)CEGUI::WindowManager::getSingleton().createWindow( "WindowsLook/StaticImage", "NewStaticImage1" );
sheet->addChildWindow( si );

I have also tried changing the last line to:
fw->addChildWindow( si );

Not only does the static image not appear anywhere on my screen, but I don't know how to make si use my "myTitle.*"

Any help is appreciated =)

User avatar
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Re: Question Using Static Images - Noobie

Postby spannerman » Thu Apr 14, 2005 17:12

I dont know if you are using OGRE, if so hopefully this code segment will help you out a bit:

Code: Select all

// materialName is the name of the material loaded by OGRE e.g "Core/OgreText"

Ogre::MaterialPtr tempMat = Ogre::MaterialManager::getSingleton().getByName(materialName);
Ogre::Pass* tempPass = tempMat->getTechnique(0)->getPass(0);
std::string textureName = tempPass->getTextureUnitState(0)->getFrameTextureName(0);
CEGUI::Texture* myTexture = myOgreCEGUIRenderer->createTexture(textureName, "myResources");

CEGUI::Imageset* tempImageSet;

if (CEGUI::ImagesetManager::getSingleton().isImagesetPresent(materialName))
   tempImageSet = CEGUI::ImagesetManager::getSingleton().getImageset(materialName);
   tempImageSet = CEGUI::ImagesetManager::getSingleton().createImageset(materialName, myTexture);

if (!tempImageSet->isImageDefined(textureName))
   tempImageSet->defineImage(textureName, CEGUI::Point(0.0f, 0.0f), CEGUI::Size(myTexture->getWidth(), myTexture->getHeight()),CEGUI::Point(0.0f,0.0f));

StaticImage* texturePanel = (StaticImage*)WindowManager::getSingleton().getWindow("NewStaticImage1");
texturePanel->setImage(materialName, textureName);

Hope that helps.

Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests