Alright, I know Frame Limiting is something that's brought up a lot, but my question is how do I do it accurately.
I've noticed that my display surface somehow never gets double-buffered, so I'm trying to find another way. Considering that 1000/60 is a decimal while SDL_GetTicks() is an integer, it's extremely hard to get an accurate 60 FPS.
So far I've tried waiting for 16ms one frame, then 17ms the next two and just repeating this cycle (updating the average every 3 frames of course). (16+17+17)/3=16.666... but my FPS calculator keeps detecting 60.049 FPS this way.
I've also tried creating a float and after waiting the desired amount of milliseconds doing while((Uint32)NextTick<=SDL_GetTicks())NextTick+=1000.0f/60.0f; Usually with the same results but with a less stable framerate.
So either my FPS counter is wrong and I'm getting 60 FPS (sometimes dipping) or I can't really get more accurate than 60.049 FPS +or-0.1
What would be the most accurate way to achieve 60 FPS without double buffering?
But to be honest, you're trying to get 60 FPS and you've got it already. You will never get exactly 60 FPS (unless casting to int) for 2 reasons.
1) (I'm assuming) you're not in total control of the system you're running on. Your application probably wont get 100% of the CPU time, at the very least the OS will keep some to render your desktop, move your mouse etc.
2) You're not in total control of the code. What if SDL_GetTicks() takes about 1 ms to generate the answer? As SDL_GetTicks() is part of your frame limiting you'll always be a little off. Same goes for variable assignment, addition, division, increment, if/loop -statements.
Those who can do, do; those who can't do, do teach.