Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > DirectX > Problem displaying text with Direct3D 8


Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2002, 02:52 PM
Roy Lazarovich
Guest
 
Posts: n/a
Default Problem displaying text with Direct3D 8


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
Reply With Quote
  #2  
Old 03-31-2002, 03:10 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

Here is a snippet from some DX code I have lying around:

Code:
    Dim CurrentFontX As D3DXFont
    Dim CurrentFont As New StdFont
    Dim CurrentColor As Long

    Dim FontDesc As IFont

    With CurrentFont
        .Name = FontName
        .Size = FontSize
        .Bold = True
        .Italic = True
    End With

    Set FontDesc = CurrentFont
    Set CurrentFontX = D3DX.CreateFont(Device, FontDesc.hFont)

    CurrentColor = &HFF0000FF

    Dim RecDest As RECT
    
    With RecDest
        .Top = 100
        .Left = 100
        .bottom = (CurrentFont.Size * 2) + 100
        .Right = (CurrentFont.Size * Len("Hello World!") * 2) + 100
    End With
    
    D3DX.DrawText CurrentFontX, CurrentColor, "Hello World!", RecDest, DT_LEFT Or DT_TOP
I'm sure you can pick something useful out of that code.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->