drawtext errors and sprites

ThePentiumGuy said:
Email microsoft for their stupidity? :-P

Ahh...but someone probably already found the bug and we would end up looking stupid. Either way, it is more fun talking about it on the forums than it is to send a bug report to microsoft. :p
 
DrawText (Alternative)

When I converted to DirectX 9.0c ran into the same problem with DrawText, it's very strict with parameters, while working with font declarations I finally got it to work as expected, when I finally got it down to where the syntax worked, the program ran but didn't display text, I later found this to be because of the DrawTextFormat settings, some settings will render the font while others won't. I've moved onto other things and now I can't find the class I made to work with DrawText easier, but even when things were going well I realized DrawText was incredibly impacting my frame rates slowing down and not doing well with memory performance, and the more text displayed the worse it was so I went in search of an alternative and considered using a generated text mesh, and behold it works like a charm.

Basically it's setup like this:

'Global Variables.
Private mesh3DText As Mesh = Nothing 'Mesh to draw 3d text.
Private fontName As String = "Arial" 'Name of the font you wish to use.
Private FontSize As Integer = 10 'Size of the font.
Private textMaterial As Material 'Material to color text.
Private matFont As Matrix = Matrix.Identity 'Matrix to position and scale. text.
Private currentFont As System.Drawing.Font 'Variable that stores the font.

'Put this code where your Direct3D device is initialized.
'Create a new font using the given parameters..
currentFont = New System.Drawing.Font(fontName, FontSize)

'Create 3D Text Mesh.
mesh3DText = Mesh.TextFromFont(mobjDX9, currentFont, "This is a test message...", 0.001F, 0.4F)

'Create the material that will be used for the mesh.
textMaterial = New Material
textMaterial.AmbientColor = New ColorValue(0, 16, 180, 255)
textMaterial.DiffuseColor = New ColorValue(0, 16, 180, 255)

'Now put this in the render portion of the program to render the text.
'Set text mesh rotation.
Dim matRot As New Matrix
matRot.RotateYawPitchRoll(0, 0, 0) 'XYZ

'Set text mesh scale.
Dim matScale As New Matrix
matScale.Scale(5.0F, 5.0F, 1.0F) 'XYZ (Note: To change font depth change Z, a higher value will result in more 3D look while lower results in a flatter 2D look.)

'Set text mesh position.
Dim matPos As New Matrix
matPos.Translate(-20, -10, 0) 'XYZ

'Combine all matrix calculations.
mobjDX9.Transform.World = Matrix.Multiply(Matrix.Multiply(matRot, matScale), matPos)

mobjDX9.Material = textMaterial 'Set material for render.
mesh3DText.DrawSubset(0) 'Render Mesh/DrawText.

:cool:
:D
 
Last edited:
Good News! If you download the new December Update of the SDK and bind to the 1.0.2903.0 version of Microsoft.DirectX.Direct3DX the no overload most specific problem goes away.
 
Back
Top