I am running into a small problem when working with render to textures while porting CEGUI to 2.2 and I'm not sure what could be the cause. When I render under OGRE 2.1, I see things get rendered like this:
But when I attempt to render this under OGRE 2.2, I see this:
Now if I attempt to resize the black area which is where the window widget should exist, I see the grey window widget being painted on the main viewport, upside down, and also reversed (e.g. text is backward) and quickly erased with the blue compositor background. This makes me think I am not doing something right in my port code for handling RenderToTexture things.
A little background, whenever CEGUI wants to render something like a basic window that could be resized and/or moved on screen, it would create a manual texture of type TU_RENDERTARGET, construct a Viewport object and associate the texture's render target to that viewport. Something akin to this very trimmed down code set.
Code: Select all
TexturePtr rtt = TextureManager::getSingleton().createManual(
getUniqueTextureName(), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D, width, height, 1, 0, PF_A8R8G8B8, TU_RENDERTARGET );
RenderTarget *rt = rtt->getBuffer()->getRenderTarget();
if ( vp_ )
{
// since we create a new RTT, if a viewport exists, destroy it.
// we have to create a new one with the new RTT.
delete vp_;
vp_ = 0;
}
vp_ = OGRE_NEW Viewport( rt, 0, 0, 1, 1 );
vp_->setDimensions(
vpDims.left() / rt->getWidth(),
vpDims.top() / rt->getHeight(),
vpDims.getWidth() / rt->getWidth(),
vpDims.getHeight() / rt->getHeight() );
Ogre::Viewport *cvp = renderSystem->_getViewport();
renderSystem->_setViewport( vp_ );
renderSystem->clearFrameBuffer( Ogre::FBT_COLOUR, ColourValue::Black );
renderSystem->_setViewport( cvp );
Code: Select all
TextureGpuManager* textureManager = d_renderSystem.getTextureGpuManager();
TextureGpu* rtt= textureManager->createTexture(
getUniqueTextureName(), GpuPageOutStrategy::Discard, TextureFlags::RenderToTexture,
TextureTypes::Type2D, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
rtt->setResolution( width, height, 1u );
rtt->setNumMipmaps( 0 );
rtt->setPixelFormat( Ogre::PFG_RGBA8_UNORM );
rtt->_transitionTo( GpuResidency::Resident, nullptr );
rtt->_setNextResidencyStatus( GpuResidency::Resident );
Code: Select all
Vector4 dims(
vpDims.left() / rtt->getWidth(),
vpDims.top() / rtt->getHeight(),
vpDims.getWidth() / rtt->getWidth(),
vpDims.getHeight() / rtt->getHeight() );
vp_->setDimensions( rtt, dims, dims );
I have forked the CEGUI repository and added a OGRE 2.2 specific branch here that contains a new RendererModule called OgreNext. This module is designed solely to work with Ogre 2.2 allowing me to remove all the fluff from legacy v1 and early v2 ports for just a clear view on whats needed. Perhaps you could point out my mistake? FWIW, OgreTextureTarget and its parent clas is where this functionality mostly resides.