Help Material -> Image

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
mac
Just popping in
Just popping in
Posts: 16
Joined: Wed Jan 12, 2005 12:06

Help Material -> Image

Postby mac » Sat Sep 25, 2004 15:37

What I did was to show the Ogre material as an overlay (because CEGUI doesn't know anything about Ogre materials) and sync the position of the overlay to the gui window.
Another idea I had was to use render to texture... but maybe Eddie has a better solution?

HTH,
mac

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Help Material -> Image

Postby CrazyEddie » Sat Sep 25, 2004 19:03

To do this you'll need to hack the code in the OgreGUIRenderer project. Basically what you're after is using an existing Ogre material/texture as the basis for an imageset. Then programatically define a CEGUI::Image on that imageset, and then use that Image for your StaticImage (and thus allowing you to put dynamically rendered content into CEGui elements. This functionality is not there *yet* but it will be a bit later on. Until then you have to hack the code yourself :)

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Help Material -> Image

Postby CrazyEddie » Mon Sep 27, 2004 09:19

I spotted a potential bug :)

Code: Select all

if ((d_ogre_texture != NULL)&(link == false))

Should possibly be:

Code: Select all

if ((d_ogre_texture != NULL) && (link == false))

Although due to the nature of the tests, the original version would work okay :)

I'm not sure I understand your code though :lol: Parts of that code were on the right track and other parts just do the same as what we have now, perhaps I missed the point entirely?

What I was going to do was something like this:

Code: Select all

//----- ogretexture.h -----
   /*!
   \brief
      Set the internal Ogre::Texture object.

   \param texture
      Reference to an Ogre::Texture object that is to be used by this Texture object.

   \return
      Nothing.
   */
   void   setOgreTexture(Ogre::Texture& texture);


//----- ogretexture.cpp -----
/*************************************************************************
   Set the internal Ogre::Texture object.
*************************************************************************/
void OgreTexture::setOgreTexture(Ogre::Texture& texture)
{
   freeOgreTexture();

   d_ogre_texture = &texture;
   d_width    = d_ogre_texture->getWidth();
   d_height = d_ogre_texture->getHeight();
   d_isLinked = true;
}

void OgreTexture::freeOgreTexture(void)
{
   if ((d_ogre_texture != NULL) && !d_isLinked)
   {
      Ogre::TextureManager::getSingleton().unload(d_ogre_texture->getName());
      d_ogre_texture->destroy();
      d_ogre_texture = NULL;
   }
}


//----- ogrerenderer.h -----
   /*!
   \brief
      Create a texture from an existing Ogre::Texture object

   \param texture
      pointer to an Ogre::Texture object to be used as the basis for the new CEGUI::Texture

   \return
      Pointer to the newly created CEGUI::Texture object.
   */
   Texture*   createTexture(Ogre::Texture* texture);


//----- ogrerenderer.cpp -----
/*************************************************************************
   Create a texture from an existing Ogre::Texture object   
*************************************************************************/
Texture* OgreRenderer::createTexture(Ogre::Texture* texture)
{
   OgreTexture* t = (OgreTexture*)createTexture();

   if (texture != NULL)
   {
      t->setOgreTexture(*texture);
   }

   return t;

}


If someone could test this out, if it works okay I'll stick it in CVS :)


CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Help Material -> Image

Postby CrazyEddie » Mon Sep 27, 2004 17:57

That's excellent. A lof of people are going to be using this ability now, I think :)

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Help Material -> Image

Postby CrazyEddie » Mon Sep 27, 2004 19:14

What about calling TextureManager::getByName(), passing the string returned from a call to RenderTexture::getName()?

User avatar
jwace81
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Wed Jan 12, 2005 12:06

Help Material -> Image

Postby jwace81 » Mon Sep 27, 2004 19:59

Doesn't Ogre::Texture derive from Resource? If so, you can just cast that Resource* to a Texture*

J.W.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Help Material -> Image

Postby CrazyEddie » Tue Sep 28, 2004 08:36

Cool, I'll add these new bits later today I think. I'll probably add a note in the docs about how to get a Texture from a RenderTexture :)

[Edit]
This new code and ability is now in CVS :)
[/Edit]

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests