Hi Gergely,
thanks for the tip. Helm sets SDL.rendererFlagPresentVSync so I guess
that takes care of that?
I followed my line of investigation a bit more and found that I can
introduce a `threadDelay 50000` just after the render call in Helm.hs
[1] which doesn't impact my application visibly but reduces the CPU
load significantly.
If you look at these definitions, this is where Helm uses Elerea.
run :: Engine -> SignalGen (Signal Element) -> IO ()
run engine gen = finally (start gen >>= run' engine) SDL.quit
run' :: Engine -> IO Element -> IO ()
run' engine smp = do
continue <- run''
when continue $ do
smp >>= render engine
threadDelay 50000 --added by me
run' engine smp
`run''` just returns false on a window close event. So really I feel
like the `start gen` call should be looking at the input signals and
seeing that nothing needs updating and therefore not calling run' as
frequently as it does.
Does that make sense? Is it achievable?
Cheers,
Kaspar
[1]:
https://github.com/switchface/helm/blob/0d96499de9fec0d95fdcf62db1b650c8a8fa9746/src/FRP/Helm.hs#L107
On 20 August 2014 06:08, Gergely Patai <
patai....@gmail.com> wrote:
> Hi Kaspar,
>
> What you probably want is to enable vsync so your framerate doesn’t
> exceed the necessary level. I don’t know if Helm makes this easy for
> you, and unfortunately I don’t know how to do this with SDL, which is
> what Helm uses under the hood as far as I know. Just search for SDL
> vsync and see if anything useful comes up.
>
> Gergely