我用c++编了一个directx9的程序,刚编一个开头,问一下为什么出错?

代码://包含的头文件#include<Windows.h>#include<d3d9.h>#pragma warning( disable :4996 )#include<strsafe.h>#pragma warning( default :4996 )//全局变量LPDIRECT3D9 g_pD3D = NULL; //DIRECT3D对象,用来创建D3DDevice对象LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; //D3DDevice对象LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; //顶点缓冲

//----------------------------------------------------------------//名称:Cleanup()//声明:在程序结束时释放内存//----------------------------------------------------------------略
//----------------------------------------------------------------//名称:MsgProc//声明:消息响应函数//----------------------------------------------------------------
略(肯定没错)

HRESULT InitD3D( HWND hWnd ){ //创建D3D对象 if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return E_FAIL;
//设置D3DDevice D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
//创建D3DDevice if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice) ) ) { return E_FAIL; } return S_OK;}
然后winmain(略)

编译器提示
1>Sp_.obj : error LNK2019: 无法解析的外部符号 _Direct3DCreate9@4,该符号在函数 "long __cdecl InitD3D(struct HWND__ *)" (?InitD3D@@YAJPAUHWND__@@@Z) 中被引用1>C:\Users\3l\Documents\Visual Studio 2010\Projects\Sp_\Debug\Sp_.exe : fatal error LNK1120: 1 个无法解析的外部命令

第1个回答  2014-01-12
_Direct3DCreate9没有定义,应该是头文件少了,为什么不直接#include "DXUT.h" 呢?
第2个回答  2014-01-12
#include "d3d9.h"
这样才对