Sign in to follow this  

Which way of using ID3DXSprite should I use.

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

Hello, Currently I'm thinking about developing 2D game on Direct3D, I'm thinking about using ID3DXSprite and ID3DXFont to draw 2D stuffs and text. In DirectX document stated that the usage of ID3DXSprite is :-
pSprite->Begin();
pSprite->Draw();
...
pSprite->Draw();
pSprite->End();
pDevice->Present();
But there are nowhere state that, should I use only 1 ID3DXSprite object, or use separate many objects to each jobs. Assume that there are 3 layers of screen - background, foreground, and text, each layer may contains several objects. And below is my current choice:- 1. Use 1 ID3DXSprite object to the whole thing :
pSprite->Begin();
//render background objects
//render foreground objects
//render text objects
pSprite->End();
pDevice->Present();
2. Use 1 ID3DXSprite object for each layer :
pSpriteBackground->Begin();
//render background objects
pSpriteBackground->End();

pSpriteForeground->Begin();
//render foreground objects
pSpriteForeground->End();

pFont1->DrawText(pSpriteText,...);
pFont1->DrawText(pSpriteText,...);
...
pDevice->Present();
3. Use 1 ID3DXSDSprite object for each object. Or, maybe there will be another way that you prefer, please discuss. Regards, Wutipong

Share this post


Link to post
Share on other sites
use one and only one ID3DXSprite to draw all three layers. calling begin and end like that is very ineffiecient. One of the best thing i would suggest you to do is store all your tiles in one tile sheet, that way you can draw the entire map in one draw call.

Share this post


Link to post
Share on other sites
You should only use one D3DXSprite object for all your sprite rendering. It manages the textures used by your sprites to minimize state changes, so by handing sprites to different D3DXSprite objects you may end up with redundant state changes as you go from one object to the next.

Share this post


Link to post
Share on other sites
The flush call tells the ID3DXSprite interface to render everything you've given it up to that call, and keep waiting for more draw calls.

There shouldn't be any reason to call it under normal use.

Share this post


Link to post
Share on other sites

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