One global ID3DXSprite for whole 2D game ? Speedup ?

Started by
1 comment, last by emiel1 14 years, 11 months ago
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)
Advertisement
I think this is a good method..there is not any reason to use more than one sprite that I can think of.
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

This topic is closed to new replies.

Advertisement