Sign in to follow this  

Possible to set a z location for sprites in clip space?

This topic is 2051 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

I am using D3DXFont to do my engine UI text , and I would like to know if there is a way to adjust its z location in clip space(0.0 - 1.0). As far as I can tell, there is no way to do this, but someone out there might have some more insight on this. Any ideas?

Thanks

Share this post


Link to post
Share on other sites
[quote name='xyzzy00']
You can control the depth at which your UI text draws something like this:


pSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE | D3DXSPRITE_SORT_DEPTH_BACKTOFRONT);

...

D3DXMATRIX xform;
D3DXMatrixTranslation(&xform, 0.0f, 0.0f, depth);
pSprite->SetTransform(&xform);
pFont->DrawText(pSprite, ...);

...

pSprite->End();



Setting the sprite transform will effect everything you draw subsequently with that sprite object. So when you draw the sprites for your other UI widgets, you'll probably want to specify 0 for the z-value of their position. And 'depth' should be a value between 0 and 1.

Also, make sure you are using the latest DXSDK. They just added the ability to specify both D3DXSPRITE_SORT_TEXTURE and D3DXSPRITE_SORT_DEPTH_BACKTOFRONT at the same time in the last update.

xyzzy[/quote]

Share this post


Link to post
Share on other sites

This topic is 2051 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this