坑已经开几天了,就从今天开始吧。书的第六章只有一个例子,而且不长,但实际上这个例子用到的框架也需要阅读,所以估计也要看很久。
class cMyHost:public cGameHost
{
public:
cMyHost(){};
~cMyHost(){};
HRESULT InitDeviceObjects();
HRESULT RestoreDeviceObjects();
HRESULT InvalidateDeviceObjects();
HRESULT DeleteDeviceObjects();
HRESULT updateScene();
HRESULT renderScene();
HRESULT OneTimeSceneInit();
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
cTerrain m_terrainSystem;
cTexture* m_pHeightMap;
cRenderMethod* m_pRenderMethod;
cSurfaceMaterial* m_pSurfaceMaterial;
};
以上就是这章用到的类,可以看到该类继承了cGameHost,所以接下来看看cGameHost类。
class cGameHost : public CD3DApplication, public cSingleton<cGameHost>
{
public:
// Creators...
cGameHost();
~cGameHost();
// Mutators...
const cSystemInfo& systemInfo()const;
cResourcePoolManager& resourceManager();
cDisplayManager& displayManager();
cLightManager& lightManager();
void setupWorldQuadTree(const cRect3d& worldExtents);
const D3DPRESENT_PARAMETERS& presentParams()const; // Parameters for CreateDevice/Reset
HWND appWindow()const; // The main app window
HWND focusWindow()const; // The D3D focus window (usually same as m_hWnd)
LPDIRECT3D9 d3dInterface()const;
LPDIRECT3DDEVICE9 d3dDevice()const; // The D3D rendering device
const D3DCAPS9& d3dCaps()const; // Caps for the device
const D3DSURFACE_DESC& d3dsdBackBuffer()const; // Surface desc of the backbuffer
const RECT& rcWindowClient()const; // Saved client area size for mode switches
const TCHAR* windowTitle()const;
bool hardwareVertexShadersAllowed()const;
void setActiveCamera(cCamera* pCamera);
void beginRenderStage(uint8 stage);
v