Search code examples
haxeopenflvsync

Is there a programmatic way to change vsync at runtime in Haxe/Starling?


I see a way to do so through project.xml but I'm not seeing a way to disable/enable vsync at runtime (like for example having an option in a settings menu or something). Searching hasn't given me any answers. :(


Solution

  • This would be up to Lime, which OpenFL is built on top of. Lime itself is built on top of SDL, but you can only access the SDL API indirectly through Lime.

    Looking through Lime sources and commit history, what you're after doesn't seem to be supported right now - the vsync flag is only passed to the initial CreateWindow() call, there doesn't seem to be a way to change it after the fact / without creating a new window.

    This same question was discussed in the OpenFL forums a few years ago. There, an idea of how this could be implemented in Lime by re-creating the SDL renderer with different flags (specifying SDL_RENDERER_PRESENTVSYNC vs not specifying it) was proposed. If you need this feature, you could consider having a go at implementing it yourself and creating a pull request.