Sign in to follow this  


Recommended Posts

I am using C++ and Direct3D9. Using D3DXSprite, how do you set a sprites position? When you use D3DXFont with D3DXSprite, how do you specify the position of the text? I want to specify the z value, so that I can make a sprite appear in front of text or vice versa. Anyone know? Someone must. I need answers :)

Share this post

Link to post
Share on other sites
The structure of the ID3DXSprite interface states that ID3DXSprite::Draw() method will give you a parameter called CONST D3DXVECTOR3 * pPosition that is used to define where the sprite is in screen space (default) but you could change this and when you begin the rendering of the sprite you can state D3DXSPRITE_OBJECTSPACE.

The world, view, and projection transforms are not modified. The transforms currently set to the device are used to transform the sprites when the batched sprites are drawn (when Flush or End is called). If this flag is not specified, then world, view, and projection transforms are modified so that sprites are drawn in screen-space coordinates.

Also for ID3DXFont, ID3DXFont::DrawText() gives you the parameter LPRECT pRect that lets you specify a rectangle to render the text into.

But... with all that said, if you are rendering the sprite before you render the text, your text should appear ontop of your sprite.

simple example

//Render your sprite
using (Sprite sprite = new Sprite(renderer.Device))
sprite.Draw(texture, new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), Color.White.ToArgb());
//Render your text
debug.Display("Frames per second: " + timer.FPS.ToString(), 16, Color.Yellow);

I hope this helps.
Take care.

Share this post

Link to post
Share on other sites

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