Browse Source

Only visible controls should be rendered

This fixes it so that only visible controls have render and prerender called.
Peter Robinson 3 years ago
parent
commit
770fffe3b0
2 changed files with 10 additions and 4 deletions
  1. 6 3
      engine/source/gui/guiCanvas.cc
  2. 4 1
      engine/source/gui/guiControl.cc

+ 6 - 3
engine/source/gui/guiCanvas.cc

@@ -1356,9 +1356,12 @@ void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */)
       for(i = begin(); i != end(); i++)
       {
          GuiControl *contentCtrl = static_cast<GuiControl*>(*i);
-         dglSetClipRect(updateUnion);
-         glDisable( GL_CULL_FACE );
-         contentCtrl->onRender(contentCtrl->getPosition(), updateUnion);
+         if (contentCtrl->isVisible())
+         {
+             dglSetClipRect(updateUnion);
+             glDisable(GL_CULL_FACE);
+             contentCtrl->onRender(contentCtrl->getPosition(), updateUnion);
+         }
       }
 
       // Tooltip resource

+ 4 - 1
engine/source/gui/guiControl.cc

@@ -918,7 +918,10 @@ void GuiControl::preRender()
    for(i = begin(); i != end(); i++)
    {
       GuiControl *ctrl = static_cast<GuiControl *>(*i);
-      ctrl->preRender();
+      if (ctrl->isVisible())
+      {
+          ctrl->preRender();
+      }
    }
    onPreRender();
 }