Issue with clipping rectangles and back to front rendering
- by Milo
Here is my problem. My rendering algorithm renders from back to front. But logically, clipping rectangles need to be applied from front to back.
Hence why the following does not work:
void AguiWidgetManager::recursiveRender(const AguiWidget *root)
{
//recursively calls itself to render widgets from back to front
AguiWidget* nonConstRoot = (AguiWidget*)root;
if(!nonConstRoot->isVisable())
{
return;
}
//push the clipping rectangle
if(nonConstRoot->isClippingChildren())
{
graphicsContext->pushClippingRect(nonConstRoot->getClippingRectangle());
}
if(nonConstRoot->isEnabled())
{
nonConstRoot->paint(AguiPaintEventArgs(true,graphicsContext));
for(std::vector<AguiWidget*>::const_iterator it =
root->getPrivateChildBeginIterator();
it != root->getPrivateChildEndIterator(); ++it)
{
recursiveRender(*it);
}
for(std::vector<AguiWidget*>::const_iterator it =
root->getChildBeginIterator();
it != root->getChildEndIterator(); ++it)
{
recursiveRender(*it);
}
}
else
{
nonConstRoot->paint(AguiPaintEventArgs(false,graphicsContext));
for(std::vector<AguiWidget*>::const_iterator it =
root->getPrivateChildBeginIterator();
it != root->getPrivateChildEndIterator(); ++it)
{
recursiveRenderDisabled(*it);
}
for(std::vector<AguiWidget*>::const_iterator it =
root->getChildBeginIterator();
it != root->getChildEndIterator(); ++it)
{
recursiveRenderDisabled(*it);
}
}
//release clipping rectangle
if(nonConstRoot->isClippingChildren())
{
graphicsContext->popClippingRect();
}
}
I could ofcourse go to the top of the tree, then apply clipping rectangles inward until I get to the currently rendered widget, but that would involve lots of clipping rectangles @ 60 frames per second. I want to minimize calls to pushing and popping rectangles.
What could I do,
Thanks