Roy Lazarovich
03-31-2002, 01:52 PM
Hello
I've been having a lot of problems displaying text on my DirectX surface, I am able to display the text, but on some computers the program crashes with an "out of memory" error.
This is my code:
in sub Main():
If Engine.DisplayFPS Then
TextRect.Top = 0
TextRect.Left = 0
TextRect.bottom = 20
TextRect.Right = 70
fnt.Bold = False
fnt.Italic = False
fnt.Name = "Arial"
fnt.Size = 8
fnt.Strikethrough = False
fnt.Underline = False
Set MainFont = d3dx.CreateFont(Device, MainFontDesc.hFont)
d3dx.DrawText MainFont, &HFFFFFFFF, "FPS: " & Game.FPS, TextRect, DT_TOP Or DT_LEFT
Set MainFont = Nothing
End If
in the D3DStart function:
Set MainFontDesc = fnt
in the general declarations:
Private MainFont As D3DXFont ' DirectX font device
Private MainFontDesc As IFont ' Font object
Private TextRect As RECT ' Rectangle information
Private fnt As New StdFont ' Standard font object
I would be very happy if you could send me a small code example of how to display text in a correct way so as not to cause errors.
Thank you very much
I've been having a lot of problems displaying text on my DirectX surface, I am able to display the text, but on some computers the program crashes with an "out of memory" error.
This is my code:
in sub Main():
If Engine.DisplayFPS Then
TextRect.Top = 0
TextRect.Left = 0
TextRect.bottom = 20
TextRect.Right = 70
fnt.Bold = False
fnt.Italic = False
fnt.Name = "Arial"
fnt.Size = 8
fnt.Strikethrough = False
fnt.Underline = False
Set MainFont = d3dx.CreateFont(Device, MainFontDesc.hFont)
d3dx.DrawText MainFont, &HFFFFFFFF, "FPS: " & Game.FPS, TextRect, DT_TOP Or DT_LEFT
Set MainFont = Nothing
End If
in the D3DStart function:
Set MainFontDesc = fnt
in the general declarations:
Private MainFont As D3DXFont ' DirectX font device
Private MainFontDesc As IFont ' Font object
Private TextRect As RECT ' Rectangle information
Private fnt As New StdFont ' Standard font object
I would be very happy if you could send me a small code example of how to display text in a correct way so as not to cause errors.
Thank you very much