Witam, mam mały problem, z rozwiązaniem niemożliwym do wygooglania.
#include
#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 = "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, "WndClass", "Lekcja 4", 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;
ID3DXEffect* pEffect;
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, 0.5f, 1, 0xffff0000,},
{ 400.0f, 100, 0.5f, 1, 0xff00ff00,},
{ 600.0f, 500, 0.5f, 1, 0xff0000ff },
};
pDev->CreateVertexBuffer(sizeof(verts), 0, OURVERT_FVF, D3DPOOL_DEFAULT, &pVB, 0);
void* data;
pVB->Lock(0, 3*sizeof(OurVertex), &data, 0);
memcpy(data, (void*)verts, sizeof(verts));
pVB->Unlock();
ID3DXBuffer* pErrs;
D3DXCreateEffectFromFile(pDev, "../1/shader.fx", 0, 0, 0, 0, &pEffect, &pErrs); //problematyczny kod@@@@@@@@@@@@@@@
if (pErrs)
{
MessageBox(hWnd, (char*)pErrs->GetBufferPointer(), "zóo", 0);
pErrs->Release();
}
MSG msg;
while(Run)
{
if (PeekMessage(&msg, 0, 0U, 0U, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
pDev->Clear(0, 0, D3DCLEAR_TARGET, 0xff000000, 1, 0);
pDev->BeginScene();
UINT passes;
D3DXHANDLE tech;
pEffect->FindNextValidTechnique(0, &tech);
pEffect->SetTechnique(tech);
pEffect->Begin(&passes,0);
for (UINT pass = 0; pass < passes; pass++)
{
pEffect->BeginPass(pass);
pDev->SetFVF(OURVERT_FVF);
pDev->SetStreamSource(0, pVB, 0, sizeof(OurVertex));
pDev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
pEffect->EndPass();
}
pEffect->End();
pDev->EndScene();
pDev->Present(0, 0, 0, 0);
if (GetKeyState(VK_ESCAPE) & 0x0800)
{
Run = false;
}
}
}
pEffect->Release();
pVB->Release();
pDev->Release();
pD3D->Release();
}
error LNK2019: unresolved external symbol _D3DXCreateEffectFromFileA@32 referenced in function _WinMain@16
Nawet ściągając i uruchamiając kod z tutoriala (http://charibo.wordpress.com/kurs-direct3d/pierwszy-shader/) cały czas to samo. VS C++ 2010 Express, biblioteki z DirectX SDK, D3DXCreateEffectFromFile zdefiniowane w d3dx9effects.h