January 26, 2021, 06:43:31 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] RefreshRate by Teddyfles [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] RefreshRate by Teddyfles [ 1+ years ago ] (Read 401 times)
BlitzBot
Jr. Member
Posts: 1
[bb] RefreshRate by Teddyfles [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:40 AM »
Title :
RefreshRate
Author :
Teddyfles
Posted :
1+ years ago
Description :
Returns the current monitor refresh rate.
Code :
Code: BlitzBasic
; RefreshRate()
; Returns the current monitor refresh rate.
; By Geert Jan Alsem
; http://geertjan.vze.com
;
; Updated version of a crappy RefreshRate() function I once wrote.
; Actually, this one is a bit strange too. Basicly it measures how
; long a VWait takes 100 times. However, it only uses the last 20
; times to calculate the result. Now the strange thing is that if
; I remove the seemingly useless first 80 runs, the function
; doesn't work as well as it does now. Apparently it needs to warm
; up first... or something...
;
; Anyway, it's a pretty useless function anyway. Just use
; WaitTimer if you want to make a game run at the same speed on
; any refresh rate.
Function
RefreshRate
(
)
Repeat
rr_timer =
MilliSecs
(
)
VWait
rr_timer =
MilliSecs
(
)
- rr_timer
If
rr_count >
79
Then
rr_total# = rr_total# +
1000
/
Float
(
rr_timer
)
rr_count = rr_count +
1
Until
rr_count =
100
Return
rr_total#/
20
End Function
Comments :
DrToxic(Posted 1+ years ago)
This is a good Function, I like how it works. perfect for my current program I'm writing.Do you mind if I suggest this small edit? We know how many times we want the Function to run, so why not For instead of Repeat. Then we can lose a line. For rr_count=0 To 100 rr_timer = MilliSecs() VWait rr_timer = MilliSecs() - rr_timer If rr_count > 80 Then rr_total# = rr_total# + 1000 / Float(rr_timer) Next Return rr_total#/20
Floyd(Posted 1+ years ago)
This doesn't work for me as VWait does nothing, i.e. does not wait.
RustyKristi(Posted 1+ years ago)
It looks like VWait is like Vertical Sync. My FPS is limited to 60 when I set this on. Also, the screen tearing is fixed when enabled..
DrToxic(Posted 1+ years ago)
VWait does work. It is the difference between my program registering 60 FPS (VWait) and 2147483648 FPS (No VWait).Honestly, the between the values is the VWait instruction.
RGR(Posted 1+ years ago)
<div class="quote">
RustyKristi wrote:
It looks like VWait is like Vertical Sync. </div>It does not even look like ... It is ... Actually you can find it in the Docs:
VWait
[frames]Parameters[frames] = optional number of frames to wait. Default is 1 frame. DescriptionVWait will cause the CPU to wait for the next (or specified number of) vertical blank event on the monitor
Matty(Posted 1+ years ago)
Personally I would have done it differently....simply had a timed pause of 1 or 2 seconds and count the number of times vwait runs....then average it.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] RefreshRate by Teddyfles [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal