drop in frame rate

Started by
2 comments, last by edwinnie 21 years, 10 months ago
okie, i got a drop in frame rate and i managed to corner down the code to:
    
CD3DFont* font = theApp.GetSmallFont();   

assert(font);               //check font


char str[10];               //char array

char str1[10];
sprintf(str, " %d", theApp.playarea[0][0]->score);  //converting int to string

sprintf(str1, " %d", theApp.playarea[0][0]->speed);

font->DrawText( 600, 380, 0x88ffff00, str, 0L ); //2D coords

font->DrawText( 600, 280, 0x88A2F69E, str1, 0L );
    
I am using CD3DFont* and the DrawText function, which both are from d3dfont.h. So, if the last line of the code above is commented out, the frame rate is ok(75+), but if it is uncommented, the frame rate drops to 25+. Whats wrong with adding the last line? //d3dfont.h HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor, TCHAR* strText, DWORD dwFlags=0L ); [edited by - edwinnie on June 3, 2002 2:34:15 AM]
Advertisement
The problem is that DrawText( ) is slow. You should write your own font engine. Search here for an example.
Lucas Henekswww.ionforge.com
D3DFont shouldn't be THAT slow. It's not the fastest font engine you can get, but it's pretty fast nonetheless. I would look at the renderstates if I were you. Try drawing only the text, without modifying any renderstates, and see what your framerate drop is. Compare your code to Text3D sample. Your framerate drop would be appropriate if you used ID3DXFont, but it's too big for D3DFont. How big are your strings?

lucinpub: Stock DrawText isn't slow unless you're drawing many strings or have very long strings. It should be quite fast for short strings. And if you do write your own font engine, D3DFont is a very good start.

[edited by - IndirectX on June 3, 2002 6:36:13 AM]
---visit #directxdev on afternet <- not just for directx, despite the name
my strings are quite small really, jus the numbers 0 to 99.
2 digits only.

This topic is closed to new replies.

Advertisement