Page 1 of 1
RTT in 0.8
Posted: Wed Sep 11, 2013 21:40
by sunflare
hi,
i'm trying to render my ogre scene into a texture and draw it in a cegui window.
everything i found online about this is outdated and contains something like this:
Code: Select all
CEGUI::Imageset& imageSet = CEGUI::ImagesetManager::getSingleton().create("RTTImageset", guiTex);it seems like CEGUI::Imageset was removed in 0.8 (was it?)
how can I draw a CEGUI::Texture without Imageset?
Re: RTT in 0.8
Posted: Tue Sep 17, 2013 09:38
by Kulik
Yes, check porting tips 0.7 to 0.8
Re: RTT in 0.8
Posted: Thu Oct 17, 2013 11:29
by Fingon
I have the same question. Based on a lot of puzzling with old code snippets, the documentation and the 0.8 changelog I've come up with the following code. But I'm still doing something wrong
Code: Select all
// make the texture
CEGUI::Texture &guiTex = mRenderer->createTexture("texname", tex);
// put the texture in an image
const CEGUI::Rectf rect(CEGUI::Vector2f(0.0f, 0.0f), guiTex.getOriginalDataSize());
CEGUI::BasicImage image("RTTImage", &guiTex, rect, CEGUI::Vector2f(0, 0), CEGUI::AutoScaledMode::ASM_Both, CEGUI::Sizef(0, 0));
// add the image to the image manager
CEGUI::ImageManager::getSingleton().addImageType<CEGUI::BasicImage>("RTTImageset");
CEGUI::ImageManager::getSingleton().create("RTTImageset", "RTTImage");
// make a static window
CEGUI::Window *si = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "RTTWindow");
si->setSize(CEGUI::USize(CEGUI::UDim(0.5f, 0), CEGUI::UDim(0.4f, 0)));
si->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5f, 0.0), CEGUI::UDim(0.0f, 0.0f)));
// set the image on the static window
si->setProperty("Image", "RTTImage");
root->addChild(si);This all runs fine, without any warnings in the cegui.log file. Until the si->setProperty("Image", "RTTImage"); line, at which the program crashes. What am I doing wrong? Or where can I find more info on RTT in cegui 0.8 ?
Thanks!
Re: RTT in 0.8
Posted: Thu Oct 17, 2013 12:59
by Fingon
I found a solution (well, somebody else did), i'll post it here too. Instead of
Code: Select all
CEGUI::BasicImage image("RTTImage", &guiTex, rect, CEGUI::Vector2f(0, 0), CEGUI::AutoScaledMode::ASM_Both, CEGUI::Sizef(0, 0));
// add the image to the image manager
CEGUI::ImageManager::getSingleton().addImageType<CEGUI::BasicImage>("RTTImageset");
CEGUI::ImageManager::getSingleton().create("RTTImageset", "RTTImage");it should be
Code: Select all
CEGUI::BasicImage* image = (CEGUI::BasicImage*)( &CEGUI::ImageManager::getSingleton().create("BasicImage","RTTImage"));
image->setTexture(&guiTex);
image->setArea(rect);
image->setAutoScaled(CEGUI::ASM_Both);I'm still wondering though if this is the intended way to do it, i.e. cast a created image to a BasicImage using pointers?
Re: RTT in 0.8
Posted: Mon Nov 11, 2013 21:37
by Ident
Yes that is how it is supposed to be done because there could be other kinds of Image than BasicImage, which do not necessarily use textures. This is actually the case in my upcoming GSOC2013 merge which uses SVGImage as well.
addImageType() is definitely not what you want to use, as the function name says it adds the type not the image itself.