• Advertisement
Sign in to follow this  

D3DXSprite render order doesn´t work

This topic is 2037 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all

I need your help. I´m writting a graphics engine and now I want to use Font system with ID3XFont.
This engine don´t have z-order and all objects are drawn at render order.
All works fine but now when I use ID3DXfont, text are drawn on top of all objects and I cant understand why.

All Objects has a matworld and are render as

void Object::RenderChild(D3DXMATRIX matWorld)
{
for(std::list<Object*>::iterator it = vctChild.begin(); it != vctChild.end(); it++)
{
Object *tmp = *it;
tmp->matWorld = matWorld;
tmp->Draw();
}
}

And calculate world transform with

void Object::gfPushMatrix()
{
vectEsc.x = Scale.X; vectEsc.y = Scale.Y; vectEsc.z = Scale.Z;
vectPos.x = (float)((int)Position.X); vectPos.y = (float)((int)Position.Y);
vectPos.z = 0;

vectRotCent.x = rotCenterPoint.X; vectRotCent.y = rotCenterPoint.Y; vectRotCent.z = rotCenterPoint.Z;
D3DXMATRIX mtxTmp;
D3DXMatrixRotationX(&Rx,D3DXToRadian(Rotation.X));
D3DXMatrixRotationY(&Ry,D3DXToRadian(Rotation.Y));
D3DXMatrixRotationZ(&Rz,D3DXToRadian(Rotation.Z));

mtxRot = Rx * Ry * Rz;
quatRot = D3DXQUATERNION();
D3DXQuaternionRotationMatrix(&quatRot, &mtxRot);
D3DXMatrixTransformation(&mtxTmp, NULL, NULL, &vectEsc, &vectRotCent, &quatRot, &vectPos);
matWorld = mtxTmp*matWorld;
GraphicsDevice_->SetTransform( D3DTS_WORLD, &matWorld); // GraphicsDevice is LPDIRECT3DDEVICE9
}

Any object do Draw as

void AnyObject::Draw()
{
gfPushMatrix();
[ Calculate position, alpha, texture clip, ...
and draw texture with LPDIRECT3DDEVICE9->DrawPrimitiveUP(...) ]
}

And my TextObject draw text in a D3DXSprite with a D3DXFont as
void TextTTF::Draw()
{
gfPushMatrix();
pTextSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE);
pTextSprite->SetTransform(&matWorld);
font->drawText(pTextSprite, text, 0,0,Color, Alignment);
pTextSprite->End();
}

I draw a background, then a text object and the many other objects which should be over the text
but the result is that text are drawn over all objects.

Any idea?
Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement