Game Development Reference
In-Depth Information
This sample and all the samples in this topic use code from the
d3dUtility.h and d3dUtility.cpp files, which can be found on this chap-
ter's web page on the topic's web site. These files contain functions
that implement common tasks that every Direct3D application will
need to do, such as creating a window, initializing Direct3D, and enter-
ing the application message loop. By wrapping up these common tasks
in functions, the samples are more focused on the particular chapter's
topic. In addition, we add useful utility code to these files as we prog-
ress through the topic.
1.5.1 d3dUtility.h/cpp
Before we get started on this chapter's sample, let's spend some time
getting familiar with the functions provided by d3dUtility.h/cpp. The
d3dUtility.h file looks like this:
// Include the main Direct3DX header file. This will include the
// other Direct3D header files we need.
#include <d3dx9.h>
namespace d3d
{
bool InitD3D(
HINSTANCE hInstance, // [in] Application instance.
int width, int height, // [in] Back buffer dimensions.
bool windowed, // [in] Windowed (true)or
// full screen (false).
D3DDEVTYPE deviceType, // [in] HAL or REF
IDirect3DDevice9** device); // [out] The created device.
int EnterMsgLoop(
bool (*ptr_display)(float timeDelta));
LRESULT CALLBACK WndProc(
HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam);
template<class T> void Release(T t)
{
if(t)
{
t->Release();
t=0;
}
}
template<class T> void Delete(T t)
{
if(t)
{
delete t;
Search WWH ::




Custom Search