Ogre::TexturePtr to CEGUI::Texture conversion

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
parul
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Feb 14, 2005 05:11

Ogre::TexturePtr to CEGUI::Texture conversion

Postby parul » Thu Apr 21, 2005 14:02

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

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

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

Postby lindquist » Fri Apr 22, 2005 16:06

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 ?

User avatar
pjcast
Quite a regular
Quite a regular
Posts: 47
Joined: Wed Jan 12, 2005 12:06

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

Postby pjcast » Fri Apr 22, 2005 19:35

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


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests