hey guys i have a problem.
Few months ago i managed to draw a triangle with this tutorial in my endscene hook:
Two-Kings - DirectX Graphics Tutorial 3: Draw Polygons
Now i wanted to try something again in directx but somehow i cant get it to work.
Drawing text works fine no problems with that but always when i try to render polygons nothing happens. (i tried in different directx 9 games not just wow)
Here is some of the current code. I really tested a lot of stuff but somehow i dont find the mistake.
Code:
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)
struct D3DVERTEX
{
float fX,
fY,
fZ;
DWORD dwColor;
};
D3DVERTEX aTriangle[] = {{-2.0f, 1.0f,10.0f,0xffff0000},
{-3.0f,-1.0f,10.0f,0xff00ff00},
{-1.0f,-1.0f,10.0f,0xff0000ff}};
Code:
void Triangle(IDirect3DDevice9 * pDevice)
{
static bool runOnce = false;
if (!runOnce)
{
runOnce = true;
pDevice->CreateVertexBuffer(sizeof(aTriangle),
D3DUSAGE_WRITEONLY,
D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT,
&pTriangleVB,
NULL);
pTriangleVB->Lock(0,sizeof(pData),(void**)&pData,0);
memcpy(pData,aTriangle,sizeof(aTriangle));
pTriangleVB->Unlock();
}
pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
/*
pDevice->SetPixelShader(0);
pDevice->SetVertexShader(0);
pDevice->Clear(0,
NULL,
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,0),
1.0f,
0);
*/
pDevice->SetStreamSource(0,pTriangleVB,0,sizeof(D3DVERTEX));
pDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,1);
}
and thats how i call the function in my endscene hook:
Code:
pDevice->CreateStateBlock(D3DSBT_ALL, &stateBlock);
stateBlock->Capture();
Triangle(pDevice);
stateBlock->Apply();
stateBlock->Release();
I would really appreciate some help . i just want to draw some simple polygons