Page 1 of 1

Ogre::TexturePtr to CEGUI::Texture conversion

Posted: Thu Apr 21, 2005 14:02
by parul
Hello Everybody
In My application I want to convert ogre::TexturePtr to CEGUI::Texture and then want to display it on our Widget. My application is crashing on startRendering ()

Below is block of code –

OgreCEGUIRenderer* renderer = (OgreCEGUIRenderer*)CEGUI::System::getSingleton().getRenderer();

CEGUI::Texture *myTextureC = renderer->createTexture((utf8*)"Cam3.jpg");

Ogre::TexturePtr txtC = ((OgreCEGUITexture*)myTextureC)->getOgreTexture();

void* tmpTxtC = (void*)(&txtC);
Ogre::TexturePtr myTexture = (Ogre::TexturePtr &)(tmpTxtC);

uint height = txtC->getHeight();
uint width = txtC->getWidth();

CEGUI::Texture *orgTexture = renderer->createTexture(myTexture);

CEGUI::Imageset* ImageSet1 =
CEGUI::ImagesetManager::getSingleton().createImageset(
(CEGUI::utf8*)"DefineImageset", orgTexture);

ImageSet1->defineImage((CEGUI::utf8*)"ogreImage",
CEGUI::Point(0.0f, 0.0f),
CEGUI::Size(width, height),
CEGUI::Point(0.0f,0.0f));

CEGUI::StaticImage* si = (CEGUI::StaticImage*)CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"TaharezLook/StaticImage", (CEGUI::utf8*)"staticimage1");

si->setSize(CEGUI::Size(0.3f, 0.2f));
si->setImage(&ImageSet1->getImage((CEGUI::utf8*)"ogreImage"));

fwnd1->addChildWindow(si);
si->setPosition(Point(0.1f,0.1f));

All code is running perfectly if I remove these lines
void* tmpTxtC = (void*)(&txtC);
Ogre::TexturePtr myTexture = (Ogre::TexturePtr &)(tmpTxtC);

but according to my requirement i have to don in this way only.
Anyone tell me what is the problem when I convert TexturePtr to (Void*) and again in TexturePtr.

Thanks
Regards
Parul

Re: Ogre::TexturePtr to CEGUI::Texture conversion

Posted: Fri Apr 22, 2005 16:06
by lindquist
how about this: ???

Code: Select all

void* tmpTxtC = (void*)(&txtC);
Ogre::TexturePtr& myTexture = *((Ogre::TexturePtr*)tmpTxtC);


and why on earth do you want to do this ?

Re: Ogre::TexturePtr to CEGUI::Texture conversion

Posted: Fri Apr 22, 2005 19:35
by pjcast
Hmm, I replied in this same post you have at the Ogre forums... If you search the forums here, you will should find your answer... If not, I also said I have an example in ogreaddons.

Casting the MaterialPtr is *NOT* neccessary (or required).