Page 1 of 1

Draw onto staticimage/window

Posted: Mon Jan 07, 2008 16:34
by ares23
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.

Posted: Mon Jan 07, 2008 16:59
by Rackle
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.

Posted: Mon Jan 07, 2008 19:46
by ares23
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?

Posted: Mon Jan 07, 2008 21:20
by scriptkid
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.