Mercurial > touhou
changeset 452:1f5156093785
By default, only enable fps limiting if vsync doesn't do the job.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Fri, 30 Aug 2013 20:38:02 +0200 |
parents | c034570ac785 |
children | 17a7f3b028f3 |
files | eosd pytouhou/ui/window.pyx |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/eosd +++ b/eosd @@ -37,7 +37,7 @@ parser.add_argument('--save-replay', met parser.add_argument('--skip-replay', action='store_true', help='Skip the replay and start to play when it’s finished') parser.add_argument('-b', '--boss-rush', action='store_true', help='Fight only bosses') parser.add_argument('--single-buffer', action='store_true', help='Disable double buffering') -parser.add_argument('--fps-limit', metavar='FPS', default=60, type=int, help='Set fps limit') +parser.add_argument('--fps-limit', metavar='FPS', default=-1, type=int, help='Set fps limit. A value of 0 disables fps limiting, while a negative value limits to 60 fps if and only if vsync doesn’t work.') parser.add_argument('--debug', action='store_true', help='Set unlimited continues, and perhaps other debug features.') parser.add_argument('--fixed-pipeline', action='store_true', help='Use the fixed pipeline instead of the new programmable one.') parser.add_argument('--no-background', action='store_false', help='Disable background display (huge performance boost on slow systems).')
--- a/pytouhou/ui/window.pyx +++ b/pytouhou/ui/window.pyx @@ -24,7 +24,7 @@ IF USE_GLEW: from pytouhou.lib.opengl cimport glewInit -class Clock(object): +class Clock: def __init__(self, fps=None): self._target_fps = 0 self._ref_tick = 0 @@ -52,10 +52,14 @@ class Clock(object): self._ref_tick = current self._ref_frame = 0 - if self._fps_frame >= (self._target_fps or 60): + if self._fps_frame >= (self._target_fps if self._target_fps > 0 else 60): self._rate = self._fps_frame * 1000. / (current - self._fps_tick) self._fps_tick = current self._fps_frame = 0 + # If we are relying on vsync, but vsync doesn't work or is higher + # than 60 fps, limit ourselves to 60 fps. + if self._target_fps < 0 and self._rate > 64.: + self._target_fps = 60 self._ref_frame += 1 self._fps_frame += 1