Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


D3DXSprite render order doesn´t work


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 hyspanux   Members   -  Reputation: 101

Like
0Likes
Like

Posted 25 June 2012 - 02:44 AM

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

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS