Sign in to follow this  
Overdose7

One global ID3DXSprite for whole 2D game ? Speedup ?

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
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

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