Share your advanced PureBasic knowledge/code with the community.
-
J. Baker
- Addict

- Posts: 2185
- Joined: Sun Apr 27, 2003 8:12 am
- Location: USA
-
Contact:
Post
by J. Baker »
Code: Select all
;before Repeat
FPSCounter = 0
OneSecond = 1
;after Repeat
Repeat
If FlipBuffers()
FPSCounter +1
EndIf
If OneSecond = 1
StartTime = ElapsedMilliseconds()
OneSecond = 0
EndIf
ElapsedTime = ElapsedMilliseconds()-StartTime
If ElapsedTime >= 1000
FinalFPS = FPSCounter
FPSCounter = 0
OneSecond = 1
EndIf
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Default)
DrawText(10, 0, "FPS " + Str(FinalFPS), RGB(255, 255, 255))
StopDrawing()
Last edited by
J. Baker on Fri Sep 03, 2010 2:10 pm, edited 1 time in total.
-
infratec
- Always Here

- Posts: 7623
- Joined: Sun Sep 07, 2008 12:45 pm
- Location: Germany
Post
by infratec »
Hi J.
hmmm,
first I would replace
with
I think it is clear why.
But in general I think it is better to use a window timer for waiting one second.
Bernd
-
J. Baker
- Addict

- Posts: 2185
- Joined: Sun Apr 27, 2003 8:12 am
- Location: USA
-
Contact:
Post
by J. Baker »
You are correct, my mistake. I updated the code.
I don't think AddWindowTimer() works in a full screen game as there's no WindowEvent().