# How can I update vSync settings after creating an SDL_Renderer?

I have an SDL_Renderer which I set to use or not use vSync depending on the user). In my options menu I have an option for enabling/disabling vSync. Can I edit my renderer to update the vSync preferences so that I don't have to destroy and recreate it? Doing so would invalidate a lot of renderer pointers in my game, so I would like to find an alternative solution.

EDIT: The following only works when executed before calling SDL_CreateRenderer. Seems like SDL has made a simple and trivial task quite hard.

SDL wiki suggests that calling SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1" or "0"); should do the trick. You might also want to try SDL_SetHintWithPriority, which will override any possible environment variables that have been set that could prevent that value passed in to SDL_SetHint to have an effect.

• Here says that this hint is used in SDL_CreateRenderer() if SDL_RENDERER_PRESENTVSYNC isn't passed. Btw, is there any way to test if vSync is being effectively active? – Xriuk Dec 27 '15 at 11:58
• You should be able to see whether VSYNC is active by disabling your framerate limiting code and then calculating your framerate. With VSYNC on, the framerate should be ~60, and without it much higher. I'll see if I can get this working on my game. – Tyyppi_77 Dec 27 '15 at 12:01
• Could you drop by the chat so we could discuss this better there? – Tyyppi_77 Dec 27 '15 at 12:06
• Tested it right now, not working. :( – Xriuk Dec 27 '15 at 12:06

Ok, I asked on the SDL Forums too:

• There is no way to edit vSync settings after renderer creation without using OpenGL.
• Destroying the renderer and re-creating it, is not an option because it will destroy every texture created with it.

So vSync shouldn't be an user-editable setting (at least for now).

• Why not just reload textures with the new renderer? – Tyyppi_77 Jan 4 '16 at 13:39
• @Tyyppi_77 That would be hell of a work, updating EVERY pointer, plus not worth it. – Xriuk Jan 4 '16 at 14:33
• That just depends on your architecture, in some cases (like in my game) textures are stored in a single place, and updating them would be really easy. – Tyyppi_77 Jan 4 '16 at 14:41
• Not useless; you could make VSync toggleable. – Tyyppi_77 Jan 4 '16 at 17:48
• I don't know why this answer got a minus one. It explains quite clearly that it can't be done unless the renderer is destroyed. Why the OP decided not to do it shouldn't change the quality of that answer. Plus one from me. – Martin Véronneau Oct 2 '19 at 16:56