z ordering of elements
Posted: Thu Aug 06, 2009 10:40
Hi, I am workging with CEGUI in ogre and I debugged rendering of all elements with NVPerfHUD. I tried only simple window with 10 icons (image + text) and rendering is not very good. Triangles are sent to GPU in following order: icon #1, text #1, icon #2, text #2, etc. Problem is caused by z-value of elements (not by OgreGUIRenderer class). I looked into CEGUI sources and it changes z value before rendering every element:
Rendering can be optimized if all child elements will have same z-value. So if window contains 10 children, all should have same z-value. If they overlap, order of rendering is not determine, but it is not big deal in such cases. I am not sure if it is possible to fix it with current z-value handling, because rendering is recursive and advancing z-value not (variable is not stored in stack). I will try to fix this issue somehow in CEGUI but I think it is good idea to fix this to improve rendering performance.
Code: Select all
/*************************************************************************
Causes the Window object to render itself.
*************************************************************************/
void Window::render(void)
{
// don't do anything if window is not visible
if (!isVisible()) {
return;
}
// signal rendering started
WindowEventArgs args(this);
onRenderingStarted(args);
// perform drawing for 'this' Window
Renderer* renderer = System::getSingleton().getRenderer();
drawSelf(renderer->getCurrentZ());
///////////////////////////////////////////////////////////////////////////////////////////////////
renderer->advanceZValue();
///////////////////////////////////////////////////////////////////////////////////////////////////
// render any child windows
size_t child_count = getChildCount();
for (size_t i = 0; i < child_count; ++i)
{
d_drawList[i]->render();
}
// signal rendering ended
onRenderingEnded(args);
}
Rendering can be optimized if all child elements will have same z-value. So if window contains 10 children, all should have same z-value. If they overlap, order of rendering is not determine, but it is not big deal in such cases. I am not sure if it is possible to fix it with current z-value handling, because rendering is recursive and advancing z-value not (variable is not stored in stack). I will try to fix this issue somehow in CEGUI but I think it is good idea to fix this to improve rendering performance.