首先是安装这个东西的问题,VC6没有自带这个,只能自己手动下载安装了,首先下载DirectX的SDK,下载后解压缩,将Include里面的文件 复制到vc目录下的
Microsoft Visual Studio\VC98\Include 下,遇到提示重复,按覆盖就是,另外一个是lib,同样将lib 里面的文件复制到Microsoft Visual Studio\VC98\lib,下遇到重复,按覆盖就是,这样基本上就解决了安装问题了,如果有不懂的回帖问变是
我照你的所说的做了但还是有错误
123.obj : error LNK2001: unresolved external symbol "bool __cdecl d3d::InitD3D(struct HINSTANCE__ *,int,int,bool,enum _D3DDEVTYPE,struct IDirect3DDevice9 * *)" (?InitD3D@d3d@@YA_NPAUHINSTANCE__@@HH_NW4_D3DDEVTYPE@@PAPAUIDirect3DDevice9@@@Z)
我是是参照 翁云兵 3D游戏程序入门
d3dUtility.h/cpp
D3D9 Init
这本书第一个例子
d3dUtility 头文件内容如下
#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;
t=0; } }
}
int d3d::EnterMsgLoop( bool (*ptr_display)(float timeDelta) )
{
MSG msg;
::ZeroMemory(&msg, sizeof(MSG));
static float lastTime = (float)timeGetTime();
while(msg.message != WM_QUIT)
{
if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{::TranslateMessage(&msg);
::DispatchMessage(&msg); }
else
{float currTime = (float)timeGetTime();
float timeDelta = (currTime - lastTime)*0.001f;
ptr_display(timeDelta); // call display function
lastTime = currTime;}
}
return msg.wParam;
}