Sign in to follow this  
kingnosis

Questions on the ID3DXSprite::Draw() Method (DX9.0)

Recommended Posts

I'm just starting with the D3DX sprite interface, and I've got several clarification questions, since MSDN seems to be less than explicit in some cases, and I can't find anything in the tutorials and forums out there. As a point of reference:
Quote:
HRESULT Draw( LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR3 *pCenter, CONST D3DXVECTOR3 *pPosition, D3DCOLOR Color );
I've ordered the questions by the function's parameters. 1) Now I know that it's a good idea to order your primitives by texture so as to avoid the overhead of switching textures all the time. Is the same true of your sprites? MSDN says that the sprites are batched - does this mean that they get ordered for me when I call End() or Flush()? 2) Usually texture coords are floats that are based on a sort of percentage of the texture, but the RECTs use longs. Is the data in the RECT supposed to be in texels? If I do need to count my pixels, I read that I need to turn off mipmapping when the file is loaded. Is that the case? 3) Does the Z value mean anything when specifying the center? I assume the center is used for doing the transforms. Does this vector specifiy the center of the source rect? MSDN says (0, 0, 0) is the upper left-hand corner. Is this the upper-left hand corner of the source rect, wherever be its position on screen? 4) The position is in screen space, just like transformed vertices with the RHW, right? 5) This is less important: what is RGBA modulation? Is it a multiplier? I know this is a lot of questions. If you can answer any of them, I'd appreciate it. kingnosis

Share this post


Link to post
Share on other sites
1) They get ordered for you if you specify the D3DXSPRITE_SORTTEXTUREE flag when calling Sprite::Begin

2) Yes the RECT data is supposed to be in texels. And yes that is the case most of the time.

3) No, it's not the upper left hand corner of the source rect. It's the upper left hand corner of the entire image. So if you were rendering a RECT(16,16,32,32) then specifying (0,0,0) as a center and then applying rotations would make the sprite "orbit". You'd have to specify 24,24 as the center. Z values make no difference AFAIK.

4) Right, unless you specify D3DXSPRITE_OBJECTSPACE as an option for Sprite::Begin

5) Modulate = multiply together.

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