www.pudn.com > D3DITEM01.rar > D3DStrat.cpp
#include "D3DInitfun.h"
#include "D3DGame.h"
IDirect3DDevice9* Device = 0; //游戏主设备接口
CGame *pGame=0; //游戏类的对象声明
CCamera *pCamera=0; //摄象机的对象声明
const int Width = 800; //游戏宽和高
const int Height = 600; //游戏的宽和高
bool StartGame(float timeDelta);
LRESULT CALLBACK d3d::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
if( wParam == VK_ESCAPE )
DestroyWindow(hwnd);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
//主函数
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE prevInstance, PSTR cmdLine,int showCmd)
{
if(!d3d::InitD3D(hinstance,Width, Height, true, D3DDEVTYPE_HAL, &Device))
{
MessageBox(0, "InitD3D failed!", 0, 0);
return 0;
}
pGame=new CGame(Device); //定义一个另外的一个类(用来初始化游戏也方便控制)
pGame->InitGame(); //游戏的初始化
d3d::EnterMsgLoop(StartGame); //函数指针的调用
Device->Release();
return 0;
}
//------------- 一个函数的过渡---------------------------------
bool StartGame(float timeDelta)
{
pGame->GameRender(timeDelta);
return true;
}