PDA

Click to See Complete Forum and Search --> : SLOW Text in DirectX


vbZombie
Apr 20th, 2000, 05:20 PM
Why oh why it's so slow to write simple text in DirectX (DirectDraw)? I have to write 100 names to screen, and no matter what I do, the program is slow ( <20 fps).

This is the code I use- about 150 fps without writing text :(
Public Sub DrawStars()
Dim xx As Integer, xy As Integer
Call g_d3dDevice.SetTexture(0, Stars(xi).texture)
TransculensyOn

For xi = 1 To Numstars
xx = Stars(xi).sRect.X1 + (Stars(xi).wdh / 2) - (TextWidth(Starnames(xi)) / 2)
xy = Stars(xi).sRect.Y2 + (Stars(xi).hgt / 2) - (TextHeight(Starnames(xi)) / 2)
Call DXOText(xx, xy, Starnames(xi), g_ddsBackBuffer)

Call g_d3dDevice.DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, Stars(xi).vertex(0), 4, 0)
Next
TransculensyOff
End Sub

KENNNY
Apr 20th, 2000, 06:27 PM
hmm yeah, it's not good Im afraid:
DirectX uses GDI32 to draw text (if you use directx in C++ you'll see - you have to use surface->GetDC then TextOut).
Anyway, this means it's slow. One thing you could do is try having a bitmap with every letter of the font on it, and draw them normally, but you'd be doing so many blits it's be slow :(

vbZombie
Apr 20th, 2000, 07:44 PM
From DirectX Help file
There are much better ways to draw text into a DirectDrawSurface, and the only point of this sample is to show exactly how to lock and access the video memory directly.


What these ways could be?? Any ideas?