Setting the game frequency

Started by JBR, July 02, 2020, 00:44:31

Previous topic - Next topic

JBR

Hi, just got a 144Hz laptop.

I have a few problems. I using B3D.

1) Flip <true> or <false> seems to be always True. I used to use False to check the speed of my code in fps.

2) I find things working well if I use Timer = CreateTimer(value). Set to 50Hz everything is super smooth. No tearing.

3) The intel cpu has a built in GPU which I think is interfering with the RTX2060. Maybe switching between CPU one and the discrete one. Maybe my imagination?

I don't want to go down the tweening road but will the createtimer() work with all pcs?

Thanks in advance, Jim.

col

Hiya,

Quotewill the createtimer() work with all pcs?
Probably, why not knock up a quick exe for people to try/verify.
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

Matty


Santiago

what is createtimer()   is a own function?

i don't understand the question, but, check if you use millisecs(), some new computer have negative values.
that if in case you using millisecs() for yout timer functions.

JBR

Hi all,

Yes it's a Blitz3D function. Don't know how it works but if you put it in your main loop it keeps your frame rate fixed.

I'm going to stick it at 60Hz as that seems to be the lowest rate for monitors in general.

Not entirely sure where in the loop I should put it - at the start?

Cheers, Jim.

Dan

Hi, here is the example from the help file:


; Create the timer to track speed
frameTimer=CreateTimer(60)

; Your main screen draw loop
While Not KeyHit(1)
WaitTimer(frameTimer) ; Pause until the timer reaches 60
Cls
; Draw your screen stuff
Flip
Wend



65536 GOTO Back2Basic

Santiago


STEVIE G

Quote from: JBR on July 02, 2020, 21:10:37
Hi all,

Yes it's a Blitz3D function. Don't know how it works but if you put it in your main loop it keeps your frame rate fixed.

I'm going to stick it at 60Hz as that seems to be the lowest rate for monitors in general.

Not entirely sure where in the loop I should put it - at the start?

Cheers, Jim.

I find putting it after flip works best.

Dan

How is delta timing calculated ?


65536 GOTO Back2Basic

Dan

65536 GOTO Back2Basic

Matty

There is another method which I use:
Create a game which on the lowest spec machine will not fall below your target frame rate desired.

In other words limit your game's fx and such that it will never fall below the target frame rate.

Then in your loop after rendering call a delay with the number of millisecs being those remaining to make up a full frame time.

Works perfectly.

STEVIE G

Quote from: Matty on July 03, 2020, 23:22:50
There is another method which I use:
Create a game which on the lowest spec machine will not fall below your target frame rate desired.

In other words limit your game's fx and such that it will never fall below the target frame rate.

Then in your loop after rendering call a delay with the number of millisecs being those remaining to make up a full frame time.

Works perfectly.

This is pretty much what waittimer does automatically. I always found deltatime jerky. My rig is v low end deliberately, including the worst gfx card (gfx710) so my (probably flawed) theory is that if I can run  it at 100 fps then everyone should be able to play it at least 60fps.

Steve Elliott

#12
@Matty, that would work for the sort of games you write, but not for all types of games.

@Stevie, that's why your games only run ok smoothly on monitor refresh rates above 60hz rather than silky smooth, and don't take advantage of the more powerful systems to deliver smoother results over slow systems.  Plus you're basically stopping the computer from doing anything for a time, which seems kinda wasteful.  You now do the maths and give options in-menu to people with 75hz monitor refresh rates - and you could expand that, so not a bad strategy I guess.  Delta-time has always given me the smoothest results (and without having to set options for every monitor refresh rate) but can be tricky to get right, and you certainly must clamp the frame speed differences between consecutive frames to a maximum level to avoid temporary spikes.

I'm very hard to please on this matter so keep trying to produce something that is a perfect solution.  In a 3D game with lots happening on-screen you won't notice any lack of smoothness.  But with a 2D scroller you will.  Maybe I've been spoilt by old systems with a set piece of computer hardware syncing perfectly to a set Monitor/TV refresh rate, but I do very much notice any stutter.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

hosch

I'm a bit late to the party, but that's the way I've done it for several years without running into problems:

Local fps% = CreateTimer(60)

Repeat

(your game code)

WaitTimer(fps)
Flip
Forever

GrindalfGames

Im not trying to hijack the thread but.....
I can CreateTimer and WaitTimer but is there anyway to get the current state of the Timer, like a GetTimer or something. There seems to be no commands for it in the helpfile and I find it very strange that it doesn't exist.