FPS ReadOut

Blitz3D Forums/Blitz3D Programming/FPS ReadOut

I use framelimiting code
FPS% = 60
PERIOD% = 1000/FPS%
TIME% = MilliSecs() - PERIOD%

While Not KeyHit(1)
	Repeat
		ELAPSED% = MilliSecs() - TIME%
	Until ELAPSED%

	TICKS% = ELAPSED%/PERIOD%
	TWEEN# = Float(ELAPSED% Mod PERIOD%)/Float(PERIOD%)

	For C = 1 To TICKS%
		If C = TICKS% Then CaptureWorld
		TIME% = TIME% + PERIOD%
		UpdateWorld
	Next

	RenderWorld TWEEN#
	
	Flip
Wend


how would i get a fps readout on the screen? meaning what is my current fps rate? text 20,20,FPS%?

Well, typically I increment some variable once per RenderWorld, then after one second that variable is the FPS. Then, normally, I reset that variable to 0 so I can restart the increment. Like this is what I use:

Global fps,timenext,frames

Function GetFPS(JustChecking = False)   ;pass True to JustChecking if you just want it to return the FPS and not increment the frames variable
                                        ;probably a good choice is to do is right after your RenderWorld GetFPS(False) and then somewhere else do Text X,Y,GetFPS(True)
	If Not JustChecking Then frames = frames+1

	If MilliSecs() > timenext Then
		timenext = MilliSecs()+1000
		fps = frames
		frames = 0
	EndIf

	Return fps
End Function


Mine is

graphics 640,480
setbuffer backbuffer()

Global fps,frame

while not keyhit(1)
    cls

	If MilliSecs()<timer+1000 Then
				frame=frame+1
	Else
				fps=frame
				frame=0
				timer=MilliSecs()
	End If

    text 0,0,fps
    flip 0

wend
end



thanks u guys the problem i have has to do with the fact that the game runs real smooth ut i get a real low framerate... how could that be?

the game framelimit is set to 60 and the fps readout i get is 16-20

You using flip false? If your not, the vsync could probably be buggering about with the framerate

using 3d? no vsync and no flip false....

How long does it take you to perform renderworld?

No flip false is your problem then. Using just Flip, will cause the program to run at the monitors refresh rate, so your probably losing fps there.