RootPanel

From Valve Developer Community
Revision as of 04:42, 6 August 2009 by TomEdwards (talk | contribs) (Created page with '{{confirm-box}} The '''RootPanel''' (strictly speaking the '''ClientDLLRootPanel''') is the ultimate parent of all VGUI elements created by a game. Unlike <code>m_pViewport</cod…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Help.png
This article contains speculation that needs to be confirmed.

The RootPanel (strictly speaking the ClientDLLRootPanel) is the ultimate parent of all VGUI elements created by a game. Unlike m_pViewport, which will point to different objects as the active ClientMode changes, the RootPanel is static.

Most games will never need to access the RootPanel. If this is true for your project then you should return the engine-controlled PANEL_CLIENTDLL instead of creating a new object, which is the behaviour of the example below.

Tip.pngTip:If you do need to access the RootPanel, then it is probably to draw an effect over the entire screen, VGUI elements included. Remember to SetPostChildPaintEnabled(true) if this is your intention.

Minimum implementation

Conventionally in vgui_rootpanel_<game>.cpp:

#include "cbase.h"
#include "ienginevgui.h"

void VGUI_CreateClientDLLRootPanel()
{
}

void VGUI_DestroyClientDLLRootPanel()
{
}

vgui::VPANEL VGui_GetClientDLLRootPanel()
{
	return enginevgui->GetPanel(PANEL_CLIENTDLL);
}

See also

  • game\client\sdk\vgui\vgui_rootpanel_sdk.cpp (for a game creating its own RootPanel)
  • ClientMode
  • VPANEL