A question about SDL_RENDERER_PRESENTVSYNC

what does it actually mean when creating a renderer with the SDL_RENDERER_PRESENTVSYNC flag set ?

i understand what vsyncing means, but WHEN is the sync happening ?

is the call to SDL_RenderPresent() actually BLOCKED until the renderer is presented ?

so suppose I call SDL_RenderPresent on a renderer that was created with the VSYNC turned on, and the monitor refresh is set to 100Hz (10msec refresh time), like this :

// draw some stuff to my_renderer
t1 = SDL_GetTicks();
SDL_RenderPresent(&my_renderer);
t2 = SDL_GetTicks();
SDL_Delay(1)
t3 = SDL_GetTicks();
SDL_RenderPresent(&my_renderer);
t4 = SDL_GetTicks();

then the time between t1 and t2 is whatever was remaining (t1 could be right before VSync, or at most 10msec before)

but the time between t2 and t3 should always be 1msec, and between t3 and t4 always 9 msec

am I correct ?

2016-06-06 11:34 GMT-03:00, jeroen clarysse <jeroen.clarysse at telenet.be>:

is the call to SDL_RenderPresent() actually BLOCKED until the renderer is
presented ?

Yep, pretty much.

Just a warning, I’d suggest you to explicitly set both this flag and
the hint (SDL_HINT_RENDER_VSYNC) to the same value. If I recall
correctly only one of them actually works but I can’t remember
which, so you may want to set both to be safe :confused:

2016-06-06 11:34 GMT-03:00, jeroen clarysse <@Jeroen_Clarysse>:

is the call to SDL_RenderPresent() actually BLOCKED until the renderer is
presented ?

Yep, pretty much.

Just a warning, I’d suggest you to explicitly set both this flag and
the hint (SDL_HINT_RENDER_VSYNC) to the same value. If I recall
correctly only one of them actually works but I can’t remember
which, so you may want to set both to be safe :confused:

thanks for that tip !

am I also correct that there is no way to turn the VSync on/off on the fly ? Only at creation of the renderer is this implemented ?

i?ve created a renderer now with all these options turned on, but my SDL_Present() call always returns within one msec? doesn?t seem to wait? is that normal ?

i?m on macos X if that is relevant?> 2016-06-06 11:34 GMT-03:00, jeroen clarysse <@Jeroen_Clarysse>:

is the call to SDL_RenderPresent() actually BLOCKED until the renderer is
presented ?

Yep, pretty much.

Just a warning, I’d suggest you to explicitly set both this flag and
the hint (SDL_HINT_RENDER_VSYNC) to the same value. If I recall
correctly only one of them actually works but I can’t remember
which, so you may want to set both to be safe :confused:

thanks for that tip !

am I also correct that there is no way to turn the VSync on/off on the fly ? Only at creation of the renderer is this implemented ?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org