• Advertisement
Sign in to follow this  

SDL - Time since last frame

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm playing around with SDL and am trying to find a way to make a TimeSinceLastFrame() kinda function. I've created a function which blits all my stuff to the screen, and to do any smooth movement I need a time since last frame function. this is in c++. I've looked at QueryPerformanceCounter() QueryPerformanceFrequency() but they don't seem to be that accurate. I must be using them wrong. Any help would be appreciated. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Quote:
..QueryPerformanceCounter()
QueryPerformanceFrequency()

but they don't seem to be that accurate. I must be using them wrong...


Well seeing as these as these are windows high resolution counters, I would say so yes.
SDL_GetTicks() or timeGetTime() may well be good enough for this tho.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:
..QueryPerformanceCounter()
QueryPerformanceFrequency()

but they don't seem to be that accurate. I must be using them wrong...


Well seeing as these as these are windows high resolution counters, I would say so yes.
SDL_GetTicks() or timeGetTime() may well be good enough for this tho.



They work accurate and its NO windows counter. Its the high performance counter on modern mainboards.

squimmy: Show us your code. Nobody can tell you whats wrong if you dont give informations.

Share this post


Link to post
Share on other sites
Here's some of the code:



lastFrameTime = thisFrameTime;
QueryPerformanceCounter(&count);
time = ((double)count.QuadPart/(double)freq.QuadPart);
thisFrameTime = time;





lastFrameTime,thisFrameTime and time are all double, they are all set up in a constructor.

I have a method called getTimeEllapsed which has:

return (thisFrameTime - lastFrameTime);


I get very strange results from it so I've obviously done something wrong, and I obviously don't understand something.


Help is very much appreciated.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement