Screen Refresh Event?

Is There any way to get an event that will indicate that the screen has been refreshed? I might not be asking this in the exact correct term. I just want an event like that so that my frames will be regulated by real time events and not by SDL_GetTick() which is good, but creates jitters sometimes and missed frames. Even if I put the frame rate to 60 FPS(like my screen), I still see that there is a frame here and there that is being skipped. I guess better time capping could solve the problem, but not guarantee a true 60 FPS, if however I would have an Event that indicates a screen refresh, I would not need to be constrained by the functionality of timers.

So is there an event like that? probably not so how hard do you think it would be to add an event like that to the SDL Event Queue?------------------------
The best of us, find happiness in misery.

First, ask yourself why you need to limit the framerate at exactly a
specific fps.On Sat, Jan 4, 2014 at 2:21 AM, helicalius wrote:

Is There any way to get an event that will indicate that the screen has been
refreshed? I might not be asking this in the exact correct term. I just want
an event like that so that my frames will be regulated by real time events
and not by SDL_GetTick() which is good, but creates jitters sometimes and
missed frames. Even if I put the frame rate to 60 FPS(like my screen), I
still see that there is a frame here and there that is being skipped. I
guess better time capping could solve the problem, but not guarantee a true
60 FPS, if however I would have an Event that indicates a screen refresh, I
would not need to be constrained by the functionality of timers.

So is there an event like that? probably not so how hard do you think it
would be to add an event like that to the SDL Event Queue?


The best of us, find happiness in misery.


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

2014/1/5 Andre D

I just want an event like that so that my frames will be regulated by real
time events

Use vsync: Create your renderer with the SDL_RENDERER_PRESENTVSYNC flag.
This will take care of any jitter (provided you can draw your scene in less
than 16ms).

Andre D wrote:

First, ask yourself why you need to limit the framerate at exactly a
specific fps.

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

very simple actually, If my screen refreshes at 60 fps, while my program updates the frame buffer 50 fps, that would mean that every 6 screen frames the frame wont change at all on the screen, and for every other it will. I dont know what this effect is called, but jitter makes sort of scense. So To solve it the only thing I need is an event that indicates that screen has refreshed. And I should be the one to choose if to update the screen every 1 frame or 2 frame or 3.------------------------
The best of us, find happiness in misery.

helicalius wrote:

Andre D wrote:

First, ask yourself why you need to limit the framerate at exactly a
specific fps.

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

very simple actually, If my screen refreshes at 60 fps, while my program updates the frame buffer 50 fps, that would mean that every 6 screen frames the frame wont change at all on the screen, and for every other it will. I dont know what this effect is called, but jitter makes sort of scense. So To solve it the only thing I need is an event that indicates that screen has refreshed. And I should be the one to choose if to update the screen every 1 frame or 2 frame or 3.

First off, nothing can guarantee a true 60 fps. No matter how finely you control things, there’s still an operating system out there that can and will put your program on hold whenever it chooses to, so that other programs have a chance to run… There is going to be “jitter” (as you call it) no matter what you do.

If you want something with a higher resolution than SDL_GetTicks(), then that’s easy enough to manage. I have one program where I have a separate thread that uses nanosleep() to create a much faster clock (and I have it creating a user event at 1/60th of a second intervals). But using that to drive the screen update doesn’t guarantee 60 fps for the reason stated above (it usually winds up an average somewhere between 59 and 60 unless the screen redraw takes too long or something else in the system causes a “hiccup”).

This article might help: http://gafferongames.com/game-physics/fix-your-timestep/On Jan 12, 2014, at 4:18 AM, helicalius wrote:

Andre D wrote:
First, ask yourself why you need to limit the framerate at exactly a
specific fps.

SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

very simple actually, If my screen refreshes at 60 fps, while my program updates the frame buffer 50 fps, that would mean that every 6 screen frames the frame wont change at all on the screen, and for every other it will. I dont know what this effect is called, but jitter makes sort of scense. So To solve it the only thing I need is an event that indicates that screen has refreshed. And I should be the one to choose if to update the screen every 1 frame or 2 frame or 3.

The best of us, find happiness in misery.


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