Game Development Reference
In-Depth Information
Manager
Since the low level details of implementing user interface objects like a button, slider,
or font renderer are beyond the scope of this topic, I
'
m going to cheat and use some
DirectX utility classes.
If you
'
ve seen any of DirectX Foundation, found in the Samples\C++\DXUT11 direc-
tory in the DirectX SDK, you
ve probably noticed that Microsoft implemented an
entire GUI system that uses the DirectX rendering pipeline and yet has most of the
functionality of traditional Windows controls. This is a nice place to start, but it does
have its drawbacks. I
'
ll show you how you can integrate this GUI system with the
game logic/game view architecture in this topic, and I will suggest some future direc-
tions. First, there
'
'
'
ll use to manage the life and access of these two
helpers. It uses the Direct3D 11 renderer to draw, which you
'
ll learn more about in
the 3D chapter. There
s a wrapper class I
s a little more to this class that you see here, but for now these
members are all you need to see to get your user interface working:
class D3DRenderer11
{
public:
// You should leave this global - it does wacky things otherwise.
static CDXUTDialogResourceManager g_DialogResourceManager;
static CDXUTTextHelper* g_pTextHelper;
'
virtual HRESULT VOnRestore()
virtual
D3DRenderer11() { SAFE_DELETE(g_pTextHelper); }
virtual bool VPreRender();
˜
// more on this later!
virtual bool VPostRender();
// more on this later!
};
// You should leave this global - it does wacky things otherwise.
CDXUTDialogResourceManager D3DRenderer::g_DialogResourceManager;
CDXUTTextHelper *D3DRenderer::g_pTextHelper = NULL;
HRESULT D3DRenderer11::VOnRestore()
{
HRESULT hr;
V_RETURN ( D3DRenderer::VOnRestore() );
SAFE_DELETE(D3DRenderer::g_pTextHelper);
D3DRenderer::g_pTextHelper = GCC_NEW CDXUTTextHelper(
DXUTGetD3D11Device(), DXUTGetD3D11DeviceContext(),
&g_DialogResourceManager, 15 );
return S_OK;
}