Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Yura

Member Since 11 Dec 2012
Offline Last Active May 06 2013 09:27 AM

Posts I've Made

In Topic: Enable the depth for text

04 April 2013 - 06:41 AM

Did you explicitely set this flag to eigther front to back or back to front?

 

I've just tried it. Didn't help.


In Topic: Enable the depth for text

04 April 2013 - 05:50 AM

Does it work if you call flush on your sprite object afterwards? Try that with different z-values..

 

No, it doesnt. Still the same. I've tried with different values


In Topic: Enable the depth for text

04 April 2013 - 03:20 AM

The King2

I've tried different variants with M32 value - result the same, text is at the top..

 

 

Jason Z

The King2 is right, I'm using Sprites for text rendering, they are out of shader at all. But if there is no other chance to enable Z-value with sprites, I'm ready to try to implement your variant


In Topic: Enable the depth for text

03 April 2013 - 04:02 AM

Can you make some explanation: what if F-value (float f)?

And m_mTransform is World matrix?

 

Naming failure ftw.

"float f" is meant to be "float z", therefore the 3rd coordinate, and therefore the depth for your text. m_mTransform initialially is an identity matrix, getting filled with the inverse (depending on how you sort your sprites - front to back or back to front, so you might want to try on that one) z coordinate. You can create it in the function call, but I decided to "cache" it in the class for (small) performance reason. So the better understandable function might go:

 

void D3DFont::DrawText(RECT rect, LPCWSTR lpText, DWORD dFlags, float z, D3DCOLOR color)
{
    D3DXMATRIX mTransform;
    D3DXMatrixIdentity(&mTransform);
    m_mTransform(3,2) = 1.0f - z;
    m_lpD3DSprite->SetTransform(&mTransform);
    m_lpFont->DrawText(m_lpD3DSprite, lpText, -1, &rect, dFlags, color);
}

 

Nope, text is still at the top

 

sprite.Begin(SpriteFlags.AlphaBlend);
Matrix matr = Matrix.Identity;
matr.M32 = -5; //hardcoded, just a try variat, primitives min z is -1
sprite.Transform = matr; //transform sprite with this matrix
SignFont.DrawText(sprite, "o", new Rectangle((int)(screenPoint.X - 1), (int)(screenPoint.Y - 1), 
                        (int)(screenPoint.X + 1), (int)(screenPoint.Y + 1)), FontDrawFlags.NoClip | FontDrawFlags.Center | FontDrawFlags.VerticalCenter, 
                        new ColorBGRA(100, 0, 255, 255));
sprite.Transform = Matrix.Identity; // after rendering text cancel transform for other elements
.............................
sprite.End();

In Topic: Enable the depth for text

03 April 2013 - 01:41 AM

You need to set transform to your sprite object. Don't know SharpDX but for pure DX9 it's like this:

 

void D3DFont::DrawText(RECT rect, LPCWSTR lpText, DWORD dFlags, float f, D3DCOLOR color)
{
	m_mTransform(3,2) = 1.0f - f;
	m_lpD3DSprite->SetTransform(&m_mTransform);
	m_lpFont->DrawText(m_lpD3DSprite, lpText, -1, &rect, dFlags, color);
}

Whereas m_mTransform is a D3DXMATRIX-object initialized to identity -> D3DXMatrixIdentity(&m_mTransform). Check out the SharpDX documentation for the equivalent to this.

 

Can you make some explanation: what if F-value (float f)? 

And m_mTransform is World matrix?


PARTNERS