Witam borykam się z pewny problemem, zalinkowałem d3d9.lib i d3dx9.lib, do folderu instalacyjnego VS2012 w którym jest miejsce na lib i include, dodałem je z Directx SDK. I wybrałem wersje lib-ów x64.
Nie wiem co robie źle, to source:
#include <d3dx9.h>
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
IDirect3D9* pD3D;
IDirect3DDevice9* pDev;
HWND hWnd;
void InitWindow()
{
HINSTANCE hProg = GetModuleHandle(0);
WNDCLASS wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hProg;
wc.lpfnWndProc = DefWindowProc;
wc.lpszClassName = L"WndClass";
wc.lpszMenuName = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hIcon = LoadIcon(hProg, IDI_WINLOGO);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.hCursor = LoadCursor(hProg, IDC_ARROW);
RegisterClass(&wc);
hWnd = CreateWindowEx(0, L"WndClass", L"Lekcja 3", WS_OVERLAPPEDWINDOW,
0, 0, 800, 600, 0, 0, hProg, 0);
ShowWindow(hWnd, 5);
}
struct OurVertex
{
float x, y, z; // pozycja
float rhw; // komponent rhw
D3DCOLOR color; // kolor
};
const DWORD OURVERT_FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE;
IDirect3DVertexBuffer9* pVB;
bool Run = true;
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
InitWindow();
pD3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Windowed = true;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &pDev);
OurVertex verts[] =
{
{ 200.0f, 500.0f, 0.5f, 1.0f, 0xffff0000,},
{ 400.0f, 100.0f, 0.5f, 1.0f, 0xff00ff00,},
{ 600.0f, 500.0f, 0.5f, 1.0f, 0xff0000ff},
};
pDev->CreateVertexBuffer(sizeof(verts),
D3DUSAGE_DYNAMIC, OURVERT_FVF, D3DPOOL_DEFAULT, &pVB, 0);
void* data;
pVB->Lock(0, 3*sizeof(OurVertex), &data, D3DLOCK_DISCARD);
memcpy(data, (void*)verts, sizeof(verts));
pVB->Unlock();
MSG msg;
while(Run)
{
if (PeekMessage(&msg, 0, 0U, 0U, PM_REMOVE))
{
if (msg.message == WM_DESTROY) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
pDev->Clear(0, 0, D3DCLEAR_TARGET, 0xff000000, 1, 0);
pDev->BeginScene();
pDev->SetFVF(OURVERT_FVF);
pDev->SetStreamSource(0, pVB, 0, sizeof(OurVertex));
pDev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
pDev->EndScene();
pDev->Present(0, 0, 0, 0);
if (GetKeyState(VK_ESCAPE) & 0x0800)
{
Run = false;
}
}
}
pDev->Release();
pD3D->Release();
}
A errory jakie mi wywala to:
Error 1 error LNK2001: unresolved external symbol _Direct3DCreate9@4
Error 2 error LNK1120: 1 unresolved externals
A na Google jedyne co znalazłem to porady że trzeba za linkować i takie pierdoły no ale to jak już wyżej napisałem zostało zrobione.
Proszę o pomoc.