VBGamer |
|
Re: displaying FPS jdchristo (0 replies, 0 views) (2001-Jan-26) i have no idea where i got this... there were probably several places, anyhow.. hope this helps... i may have left out a thing or two...
'variables used to calculate framerate
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public FPS_LastCheck As Long
Public FPS_count As Long
Public FPS_Current As Integer
Public fps as integer
Public Sub ComputeFPS()
'#########
'## FONTS ##
'#########
Public MainFont As D3DXFont
Public MainFontDesc As IFont
Public TextRect As RECT
Public fnt As New StdFont
'Frame rate calculations
If GetTickCount() - FPS_LastCheck >= 1000 Then
FPS_Current = fps
fps = 0 'reset the counter
FPS_LastCheck = GetTickCount()
End If
fps = fps + 1
End Sub
'this should be located in the main render loop for the text
'##########
'## FONTS ##
'#########
fnt.Name = "Verdana"
fnt.Size = 12
Set MainFontDesc = fnt
Set MainFont = g_D3DX.CreateFont(g_D3DDevice, MainFontDesc.hFont)
'Draw the frame rate
TextRect.Top = 0
TextRect.bottom = 20
TextRect.Right = 75
g_D3DX.DrawText MainFont, &HFFFFCC00, CStr(FPS_Current) & "fps", TextRect, DT_TOP Or DT_LEFT
jon christopher |