Skip to main content
gamedev.net
🔒 Locked

Basic 2D Text

Started by amt35 Oct 29, 2004 at 10:03 AM 1 replies 950+ views
Original Post
amt35
amt35
I'm new with DirectX. How do I draw Text to the screen? Can you draw text with a certain font with DirectX? Thanks, Andrew
achumack
achumack
D3DXFont, or looking for DXSDK\C++\COMMON\INCLUDE\d3dfont.h
and \src\d3dfont.cpp
( I saw it in DirectX9.0 SDK )
ruddermode
ruddermode
This is what I'm doing to temporarily output some plain text -
(using vb.net but the principle should be the same)

Font variable declaration -

Private outputFont As Microsoft.DirectX.Direct3D.Font = Nothing



During graphics initialisation -

outputFont = New Microsoft.DirectX.Direct3D.Font(device, New System.Drawing.Font("Arial", 8.0F, Fontstyle.Bold))


A subroutine to draw the text -


Private Sub Draw2DText(ByVal strText As String, ByVal x As Integer, ByVal y As Integer, ByVal c As Color)    outputFont.DrawText(strText, New Rectangle(x, y, 0, 0), DrawTextFormat.NoClip Or DrawTextFormat.ExpandTabs, c)End Sub 'Draw2DText



And then in the OnPaint -

Draw2DText("message 1 : " & message1, 5, 30, Color.Black)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.