编译一个最简单的带 DirecTX 的问题, 连接问题, 不明白 高手指点一下!!!!!!!!!!
sql1 2005-03-30 10:52:55
Linking...
chenxu.obj : error LNK2001: unresolved external symbol _Direct3DCreate9@4
Debug/chenxu.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
#include<windows.h>
#include<windowsx.h>
#include<d3d9.h>
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
LPDIRECT3D9 g_pD3D=NULL;
LPDIRECT3DDEVICE9 g_pd3dDevice=NULL;
HRESULT InitD3D(HWND hwnd)
{
if(NULL==(g_pD3D=Direct3DCreate9(D3D_SDK_VERSION)))
return E_FAIL;
D3DDISPLAYMODE d3ddm;
if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm)))
return E_FAIL;
D3DPRESENT_PARAMETERS stPresentParam;
ZeroMemory(&stPresentParam,sizeof(stPresentParam));
stPresentParam.Windowed=TRUE;
stPresentParam.SwapEffect=D3DSWAPEFFECT_DISCARD;
stPresentParam.BackBufferFormat=d3ddm.Format;
if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,&stPresentParam,&g_pd3dDevice)))
{
return E_FAIL;
}
return S_OK;
}
void Cleanup()
{
if(g_pd3dDevice!=NULL)
g_pd3dDevice->Release();
if(g_pD3D!=NULL)
g_pD3D->Release();
}
void Render()
{
if(NULL==g_pd3dDevice)
return;
g_pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,255),1.0F,0);
g_pd3dDevice->BeginScene();
g_pd3dDevice->EndScene();
g_pd3dDevice->Present(NULL,NULL,NULL,NULL);
}
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hpreinstance,LPSTR lpcmdline,int ncmdshow)
{
HWND hwnd;
MSG msg;
WNDCLASS winclass;
winclass.style=CS_HREDRAW|CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(hinstance,"IDI_ICON2");
winclass.hCursor=NULL;;
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName=NULL;
winclass.lpszClassName="WINCLASS1";
winclass.hIcon=NULL;
RegisterClass(&winclass);
hwnd=CreateWindow("WINCLASS1","GUOYIWE WINDOWS",WS_OVERLAPPEDWINDOW,0,0,400,400,NULL,NULL,hinstance,NULL);
if(SUCCEEDED(InitD3D(hwnd)))
{
ShowWindow(hwnd,3);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Cleanup();
return 1;
}
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
switch(msg)
{
case WM_PAINT:
Render();
ValidateRect(hwnd,NULL);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
}
return(DefWindowProc(hwnd,msg,wparam,lparam));
}