[Webkit-unassigned] [Bug 173434] Support for 120Hz requestAnimationFrame

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 18 23:42:47 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=173434

--- Comment #15 from jdspugh <jdspugh at gmail.com> ---
The refreshRate is redundant for the requestAnimationFrame function. You only need requestAnimationFrame(fn). Your code will be like this:

const FPS = 240
const MILLISECONDS_PER_FRAME = 1000 / FPS
let tStart = Date.now()
let tickTarget, tick = 0
function fn() {
  tickTarget = (Date.now() - tStart) / MILLISECONDS_PER_FRAME
  while (tick < tickTarget) {
    // perform MILLISECONDS_PER_FRAME worth of game animation calculations
  }
  // render your game
  requestAnimationFrame(fn)
}
requestAnimationFrame(fn)

Now your game will run with maximum smoothness at any refresh rate up to 240fps. It's really just the basics of game programming ;)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210819/1c55245c/attachment-0001.htm>


More information about the webkit-unassigned mailing list