Jump to content
  • Advertisement
Sign in to follow this  
Overdose7

One global ID3DXSprite for whole 2D game ? Speedup ?

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

Hey guys, Is good idea to use a one sprite(ID3DXSprite) for whole 2D game ? I have one global sprite that I'm using for: -Texture rendering (using ID3DXSprite for drawing textures) -Font rendering (First parameter in DrawTextA) And I'm using that in this way:
Quote:
D3DDevice.BeginScene(); FSpriteRenderer.BeginRender(); D3DXSprite.Begin(D3DXSPRITE_OBJECTSPACE or D3DXSPRITE_DO_NOT_ADDREF_TEXTURE); // Draw everything for current frame, including texts D3DXSprite.Flush; D3DXSprite.End; D3DDevice.EndScene();
So my question is: Is this correct ? Is there any speedup by using only one sprite ? (begin and end is called only once per frame)

Share this post


Link to post
Share on other sites
Advertisement
There is some performance gain in using only one ID3DXSprite interface. The sprite-interface locks a vertexbuffer and unlocks + renders it when you call End(). Doing this twice takes some time, but not noticable. Also, using one interface, means that the sprite-interface can batch more, and thus reduces rendertime.

One last thing: Flush()ing before you End() takes some time and is unneeded:
- Flush(): Unlocks the dynamic vertexbuffer, draws everything in that buffer, locks the dynamic vertexbuffer.
- End(): Unlocks the dynamic vertexbuffer, draws everything in that buffer.
Removing the Flush() means skipping the extra lock+unlock.

Emiel1

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!