hello-
i am not sure what i am doing wrong, but i can't get the quad to render. directx is set up properly, i can render things, but i can't get the quad class to do its thing. i think it might be the way i am describing the quad.
Here is the functiont to create the billboard:
void cBillboard::CreateBillboard()
{
HRESULT r;
VOID* pVertices;
v = new CUSTOM_VERTEX[4];
//create the vertical info.
//thisprobably cold only happen once if the billboard isn't changing, but it works for now
v[0].x = 0.0f;
v[0].y = 0.0f;
v[0].z = 0.0f;
v[0].color = myColor;
v[0].u = 0.0f;
v[0].v = 1.0f;
v[1].x = myWidth;
v[1].y = 0.0f;
v[1].z = 0.0f;
v[1].color = myColor;
v[1].u = 1.0f;
v[1].v = 1.0f;
v[2].x = myWidth;
v[2].y = myHeight;
v[2].z = 0.0f;
v[2].color = myColor;
v[2].u = 1.0f;
v[2].v = 0.0f;
v[3].x = 0.0f;
v[3].y = myHeight;
v[3].z = 0;
v[3].color = myColor;
v[3].u = 0.0f;
v[3].v = 0.0f;
r = VB->Lock( 0, 0, (VOID**)&pVertices, 0 );
if(r != D3D_OK)
{
gLog<<"cBillboard: Failed to lock vertex the buffer. "<<DXGetErrorString(r)<<endl;
return;
}
memcpy(pVertices, v, sizeof(v));
VB->Unlock();
}
here is the render code:
void cBillboard::render()
{
D3DXMATRIX final, trans;
D3DXMatrixIdentity(&final);
D3DXMatrixTranslation(&trans, Position.x, Position.y, Position.z);
D3DXMatrixMultiply(&final, &final, &trans);
Game->GetDX()->GetRenderer()->GetDevice()->SetTransform(D3DTS_WORLD, &final);
gLog<<"rendering."<<endl;
Game->GetDX()->GetRenderer()->GetDevice()->SetTexture(0, myTexture);
Game->GetDX()->GetRenderer()->GetDevice()->SetStreamSource(0, VB, 0, sizeof(CUSTOM_VERTEX));
Game->GetDX()->GetRenderer()->GetDevice()->SetFVF(FVF());
Game->GetDX()->GetRenderer()->GetDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 1);
}
here is the constructor:
cBillboard::cBillboard(LPDIRECT3DTEXTURE9 Texture, float x, float y, float z, float tu, float tv, UINT w, UINT h)
{
myTexture = Texture;
SetPosition(x, y, z);
texu = tu;
texv = tv;
myColor = D3DCOLOR_ARGB(255,0,0,0);
myWidth = w;
myHeight = h;
v = 0;
VB = NULL;
HRESULT r;
r = Game->GetDX()->GetRenderer()->GetDevice()->CreateVertexBuffer((4*sizeof(CUSTOM_VERTEX)), 0, FVF(), D3DPOOL_DEFAULT, &VB, NULL);
if(r != D3D_OK)
{
gLog<<"cBillboard: error creating vertex buffer. "<<DXGetErrorString(r)<<endl;
delete this;
}
CreateBillboard();
}
any ideas would be greatly appretiated.
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.