Reputation: 16548
I am attempting to improve the directx performance of a well tested working application. Using a profile tool, I have pinpointed that a call to Microsoft.DirectX.Direct3D.Font.DrawText(Sprite sprite, string text, int x, int y, int color) with null passed for the sprite parameter is responsible for approximately 30% of the application's CPU usage. When I create a sprite and pass it to all calls of DrawText the CPU usage is close to eliminated. The only problem is the font gets really small and rotated in a way that isn't legible.
Can anyone create a sprite that will render text in the same way that passing null to Microsoft.DirectX.Direct3D.Font.DrawText(Sprite sprite, string text, int x, int y, int color) does? I know there are ways to use 2D text instead of what I have but would prefer to avoid making big changes to this working app.
Upvotes: 0
Views: 543
Reputation: 32597
You should place the draw calls between Sprite.Begin()
and Sprite.End()
. The Begin()
call will apply appropriate render states (e.g. transformations) and the End()
call restores the previous state. Of course, you should not draw anything other than sprites within this block.
Upvotes: 1