Does anyone have a function or some code that displays the framerate?
Showing Framerate with DrawText()?
BlitzMax Forums/BlitzMax Programming/Showing Framerate with DrawText()? I found this here on the forum:
Local FPS_Counter:Int
Local FPS_Counter_Time:Int
Local FPS:Int
FPS_Counter=FPS_Counter+1
If FPS_Counter_time+1000 =< MilliSecs()
FPS=FPS_Counter' <- Frames/Sec
FPS_Counter=0
FPS_Counter_time=MilliSecs()
EndIf
DrawText "Current FPS: "+FPS,20,20
but it doesnt seem to work?
Local FPS_Counter:Int
Local FPS_Counter_Time:Int
Local FPS:Int
FPS_Counter=FPS_Counter+1
If FPS_Counter_time+1000 =< MilliSecs()
FPS=FPS_Counter' <- Frames/Sec
FPS_Counter=0
FPS_Counter_time=MilliSecs()
EndIf
DrawText "Current FPS: "+FPS,20,20
but it doesnt seem to work?
Graphics 640, 480,0 Local FPS_Counter:Int Local FPS_Counter_Time:Int Local FPS:Int While Not KeyDown(KEY_ESCAPE) FPS_Counter = FPS_Counter + 1 If FPS_Counter_time+1000 =< MilliSecs() FPS=FPS_Counter' <- Frames/Sec FPS_Counter=0 FPS_Counter_time=MilliSecs() EndIf DrawText "Current FPS: " + FPS , 20 , 20 Flip Cls Wend End
Something like this should work (untested tho). All it does is count the number of screen updates, then store the result in a separate var at the end of each second:
Global FramesPerSec:int Global FrameCounter:int Global Start:int While Not KeyDown(KEY_ESCAPE) 'do stuff UpdateFrameCounter() DrawText "FPS: " + FramesPerSec,10,10 Flip Wend Function UpdateFrameCounter() FrameCounter:+1 If Millisecs() > Start + 1000 Start = Millisecs() FramesPerSec = FrameCounter FrameCounter = 0 EndIf End Function
@GFX
when I use your version, it remains almost at all times at 61 FPS. sometimes 60 FPS. then again, there is nothing going on right now except some drawtext commands
when I use your version, it remains almost at all times at 61 FPS. sometimes 60 FPS. then again, there is nothing going on right now except some drawtext commands
that's because the hertz value of the graphic command is at 60 by default, set it to 0 to allow unlimited updates
hey man! Thanks!! I will try that! where is the 0 explained in the documentation by the way?
oh
my graphics command is:
Graphics 800,600, 1
(1 for fullscreen)
now if I add like you say:
Graphics 800,600, 1, 0
I still get a framerate of 1 (split second) then 60 or 61 constantly
my graphics command is:
Graphics 800,600, 1
(1 for fullscreen)
now if I add like you say:
Graphics 800,600, 1, 0
I still get a framerate of 1 (split second) then 60 or 61 constantly
You'll need to change 'Flip' to 'Flip 0'. (disables vSync, basically).
wow ... when i do that! I get a framerate of 3400-3500 ... ????
Sounds about right...
sounds about right (insert shocked face here)??? please explain
Well, all the code is doing, is drawing a line of text.
Disabling vSync means that your PC is going to redraw the screen as fast as it possibly can, so frame rates of 3000+FPS are not uncommon. Framerate is dependent on hardware, obviously.
Disabling vSync means that your PC is going to redraw the screen as fast as it possibly can, so frame rates of 3000+FPS are not uncommon. Framerate is dependent on hardware, obviously.
I must not understand then; i believed the highest framerate was 60 per second for NTSC 50 FPS for PAL regions.
The code is measuring the speed of logic cycles not monitor refresh rates.
What release of Bmax are you using? If not BMAX 1.24 you should upgrade.
The documentation for Graphics command states
What release of Bmax are you using? If not BMAX 1.24 you should upgrade.
The documentation for Graphics command states
This value can be 0, 16, 24 or 32 depending on the graphics modes available
so you shouldn't really be setting 1 for 'depth'. I am using the 1.24; oh, and the "1" does into fullscreen, whereas if i use "0" i run windowed ...
and the "1" does into fullscreen
... and so does any non-0 number. However, that parm is the depth and *SHOULD* be set to 16,24 or 32.
okie dokey!