Draw onto staticimage/window

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

ares23
Just popping in
Just popping in
Posts: 10
Joined: Mon Jan 07, 2008 00:25

Draw onto staticimage/window

Postby ares23 » Mon Jan 07, 2008 16:34

Hello!

I have a staticimage/window that it created using the following:

Code: Select all

      CEGUI::Texture *cetex = mguirenderer->createTexture("terrain_texture.jpg", "General");
      CEGUI::Imageset* imageset = CEGUI::ImagesetManager::getSingleton().createImageset("minimapTexImageset", cetex);

      imageset->defineImage("minimapImage", CEGUI::Point(0.0f, 0.0f), CEGUI::Size(cetex->getWidth(), cetex->getHeight()), CEGUI::Point(0.0f,0.0f));

      mapwindow = CEGUI::WindowManager::getSingleton().getWindow("Root/MiniMap");
      mapwindow->setProperty("Image", CEGUI::PropertyHelper::imageToString(&imageset->getImage("minimapImage")));


Can anyone tell me how I can draw arbitary lines/rectangles onto the window?

Thanks.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Mon Jan 07, 2008 16:59

I don't know how to accomplish this strickly within Cegui, a GUI library. The solution may probably found within the rendering library, which would dynamically update the image displayed within the StaticImage.

Ogre's CEGUIBuildDialog animates images by rendering rotating meshes onto a texture which is then used by Cegui. The code may seem overwhelming at first but is relatively easy to follow. Hopefully your renderer can support a feature similar to this one.

ares23
Just popping in
Just popping in
Posts: 10
Joined: Mon Jan 07, 2008 00:25

Postby ares23 » Mon Jan 07, 2008 19:46

Thanks for the link Rackle. It was a little overkill for what I needed but it lead me down the right path. Below is the code I have ended up with:

Code: Select all

      unsigned int *m_pMapBuffer[1024];
      for (int i=0; i<1024; i++)
      {
         m_pMapBuffer[i] = (unsigned int*)((181 <<  16) |(181 <<  8) |(181 << 16) |(255 << 24));
      }
      
      CEGUI::Texture *txt = mguirenderer->createTexture();
      txt->loadFromMemory(&m_pMapBuffer, 30, 30, CEGUI::Texture::PF_RGBA);
 
      CEGUI::Imageset *imageset = CEGUI::ImagesetManager::getSingleton().createImageset("minimapTexImageset", txt);
      imageset->defineImage("minimapImage", CEGUI::Point(0.0f, 0.0f), CEGUI::Size(txt->getWidth(), txt->getHeight()), CEGUI::Point(0.0f,0.0f));

      mapwindow = CEGUI::WindowManager::getSingleton().getWindow("Root/MiniMap");
      mapwindow->setProperty("Image", CEGUI::PropertyHelper::imageToString(&imageset->getImage("minimapImage")));


This works nicely and provides a mechanism to dynamically alter the texture which is rendered to the window.

Now, I need to find a way to load an image file into the m_pMapBuffer in the first place. CEGUI::Texture only provides a means to load from a memory buffer but not to output to one.

Any suggestions how to get an image file into my buffer?

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Mon Jan 07, 2008 21:20

Hi,

i've had a quick look at both the renderers and the imagecodecs, but it seems that none provide a way to get the original bytes. Only the OpenGLTexture.h defines a method 'grabTexture' which might be usefull.

So, unless i'm wrong i am affraight that you need to do some good 'ol file reading by yourself...

HTH.
Check out my released snake game using Cegui!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 16 guests