Page 1 of 1

Help Material -> Image

Posted: Sat Sep 25, 2004 15:37
by mac
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

Help Material -> Image

Posted: Sat Sep 25, 2004 19:03
by CrazyEddie
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.

Help Material -> Image

Posted: Mon Sep 27, 2004 09:19
by CrazyEddie
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.

Help Material -> Image

Posted: Mon Sep 27, 2004 17:57
by CrazyEddie
That's excellent. A lof of people are going to be using this ability now, I think :)

CE.

Help Material -> Image

Posted: Mon Sep 27, 2004 19:14
by CrazyEddie
What about calling TextureManager::getByName(), passing the string returned from a call to RenderTexture::getName()?

Help Material -> Image

Posted: Mon Sep 27, 2004 19:59
by jwace81
Doesn't Ogre::Texture derive from Resource? If so, you can just cast that Resource* to a Texture*

J.W.

Help Material -> Image

Posted: Tue Sep 28, 2004 08:36
by CrazyEddie
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.