I am trying to draw a billboard with a tree texture. The texture has a black background with a tree in the middle. The problem is i can't seem to make it transparent. It always has this black box around it. I have tried to remove it using a colorkey by loading the texture like this:
D3DXCreateTextureFromFileExA(D3D9_Device,FileName.str().c_str() , D3DX_DEFAULT,D3DX_DEFAULT,D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(0, 0, 0), 0, 0 ,&Oak);
here is the drawing code
//Draws tree billboard
D3D9_Device->SetVertexDeclaration(Billboard_Declaration);
D3D9_Device->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE );
D3D9_Device->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE );
D3D9_Device->SetRenderState(D3DRS_POINTSIZE, FWORD(1.0f) );
D3D9_Device->SetRenderState(D3DRS_POINTSIZE_MIN, FWORD(0.0f) );
D3D9_Device->SetRenderState(D3DRS_POINTSCALE_A, FWORD(1.0f) );
D3D9_Device->SetRenderState(D3DRS_POINTSCALE_B, FWORD(1.0f) );
D3D9_Device->SetRenderState(D3DRS_POINTSCALE_C, FWORD(1.0f) ); /
D3D9_Device->SetRenderState(D3DRS_LIGHTING, FALSE );
D3D9_Device->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
D3D9_Device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
D3D9_Device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
D3D9_Device->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
Billboard_Vertex* V;
SAFE_RELEASE(VB_Oak);
D3D9_Device->CreateVertexBuffer(1*sizeof(Billboard_Vertex),Usage | D3DUSAGE_POINTS, 0, Pool, &VB_Oak, 0);
VB_Oak->Lock(0,1*sizeof(Billboard_Vertex),(void**) &V,0);
V[0].Position = D3DXVECTOR3(0,0,0);
V[0].Color = 0xFFFFFFFF;
VB_Oak->Unlock();
D3D9_Device->SetTexture(0,Oak);
D3D9_Device->SetStreamSource(0,VB_Oak,0,sizeof(Billboard_Vertex));
D3D9_Device->DrawPrimitive(D3DPT_POINTLIST,0,1);
And here are the declarations
struct Billboard_Vertex
{
D3DXVECTOR3 Position;
D3DCOLOR Color;
};
LPDIRECT3DVERTEXDECLARATION9 Billboard_Declaration;
D3DVERTEXELEMENT9 Billboard_Elements[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
D3DDECL_END()
};
IDirect3DTexture9* Oak; //oak tree texture
LPDIRECT3DVERTEXBUFFER9 VB_Oak; //vertex buffer
I have been working on this problem for hours . Any ideas on why its not working? Thanks.