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
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.