Viewport::clearFrame

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Viewport::clearFrame

Post by KungFooMasta »

In Short: Can we add the following API?

void Viewport::clearFrame(unsigned int buffers = FBT_COLOUR | FBT_DEPTH);

How it would help me:

I don't want the viewport to be cleared every frame, but if I set this option to false, I see garbage data on my screen. I'm at work and can't easily trace through the code to see how the viewport actually gets cleared (its not in OgreViewport.cpp, some other class does the actual clearing of the contents). It would be nice to be able to clear the viewport on demand, or at least queue the request for the appropriate time (next frame).

If this helps, this is my setup, where I experience the issue:

Code: Select all

	void SCFogOfWar::_setupVisitedTexture()
	{
		mVisitedTextureName = "FogOfWarVisitedRTT";

		Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( mVisitedTextureName, 
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 
			512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);

		mVisitedTextureRenderTarget = texture->getBuffer()->getRenderTarget();

		// Add FoW camera as a source to the Texture's render target
		mVisitedTextureViewport = mVisitedTextureRenderTarget->addViewport(mFoWCam);
		//mVisitedTextureViewport->setClearEveryFrame(false);
	}
Creator of QuickGUI!
User avatar
Archangel
Greenskin
Posts: 101
Joined: Sun Dec 19, 2004 6:02 pm
Location: Nantes, France
Contact:

Re: Viewport::clearFrame

Post by Archangel »

You could try this :

Code: Select all

Ogre::RenderSystem* pRS = Ogre::Root::getSingletonPtr()->getRenderSystem();
pRS->_setViewport(pViewport);
pRS->clearFrameBuffer(Ogre::FBT_COLOUR, mColor);
I'm not sure it'll work in your case, but that's the code I use in my GUI (which does not use "set and forget" rendering).
Arch. / Kalith
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Re: Viewport::clearFrame

Post by KungFooMasta »

I believe your solution is correct, somebody suggested that in another thread and it worked for me. Still it would be a convenient function to have IMO. If we have the ability to clear the buffer every frame, we should have the ability to clear it in a less automatic manner. I guess it would be low priority, but the solution is basically to write a function and put in code similar to what you wrote. :)
Creator of QuickGUI!
User avatar
Archangel
Greenskin
Posts: 101
Joined: Sun Dec 19, 2004 6:02 pm
Location: Nantes, France
Contact:

Re: Viewport::clearFrame

Post by Archangel »

Agreed ;)
Arch. / Kalith
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Re: Viewport::clearFrame

Post by sinbad »

A fair request, I'll add it.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Re: Viewport::clearFrame

Post by KungFooMasta »

Thanks! :D
Creator of QuickGUI!
Post Reply