(#39) Unhardcode refresh rate

This commit is contained in:
rexim 2019-12-05 00:45:58 +07:00
parent de52f98371
commit f0ea6a8fec
3 changed files with 3 additions and 5 deletions

View File

@ -286,6 +286,7 @@ proc main() =
isEnabled: false,
radius: 200.0)
let dt = 1.0 / rate.float
while not quitting:
var wa: TXWindowAttributes
discard XGetWindowAttributes(display, win, addr wa)
@ -308,7 +309,7 @@ proc main() =
# delta is the distance the mouse traveled in a single
# frame. To turn the velocity into units/second we need to
# multiple it by FPS.
camera.velocity = delta * config.fps.float
camera.velocity = delta * rate.float
mouse.prev = mouse.curr
@ -383,7 +384,6 @@ proc main() =
else:
discard
let dt = 1.0 / config.fps.float
camera.update(config, dt, mouse, screenshot,
vec2(wa.width.float32, wa.height.float32))
flashlight.update(dt)
@ -393,5 +393,6 @@ proc main() =
mouse, flashlight)
glXSwapBuffers(display, win)
glFinish()
main()

View File

@ -4,13 +4,11 @@ type Config* = object
scrollSpeed*: float
dragFriction*: float
scaleFriction*: float
fps*: int
const defaultConfig* = Config(
scrollSpeed: 1.5,
dragFriction: 6.0,
scaleFriction: 4.0,
fps: 60
)
macro parseObject(obj: typed, key, val: string) =

View File

@ -1,4 +1,3 @@
import math
import config
import la
import image