• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

101 Neutral

About hyspanux

  • Rank
  1. 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
  • Advertisement