Page 1 of 1

Question Using Static Images - Noobie

Posted: Mon Apr 11, 2005 20:04
by kungfoomasta
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.


Re: Question Using Static Images - Noobie

Posted: Tue Apr 12, 2005 22:25
by lindquist

Code: Select all

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

Re: Question Using Static Images - Noobie

Posted: Thu Apr 14, 2005 05:04
by kungfoomasta
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 =)

Re: Question Using Static Images - Noobie

Posted: Thu Apr 14, 2005 17:12
by spannerman
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.