Jump to content

  • Log In with Google      Sign In   
  • Create Account


"Frames" per second in Win32 console application


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 dAND3h   Members   -  Reputation: 214

Like
0Likes
Like

Posted 12 November 2012 - 04:48 PM

Hi, I am wondering if there is a function such as SDL_GetTicks() native to windows? I want to limit how often my update and draw methods execute inside my console application.

I am making an ascii game. Any help is appreciated, thanks.

Sponsor:

#2 fastcall22   Crossbones+   -  Reputation: 4033

Like
2Likes
Like

Posted 12 November 2012 - 04:55 PM

Off the top of my head:
timeGetTime (winmm.lib, millisecond resolution, and deprecated?)
GetPerformanceFrequency and GetPerformanceCounter (highest resolution timer, may be inconsistent across multiple cores)

There may be others...

Edited by fastcall22, 12 November 2012 - 04:56 PM.

c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#3 incertia   Crossbones+   -  Reputation: 777

Like
1Likes
Like

Posted 12 November 2012 - 09:43 PM

GetTickCount()
is another, but it's not very reliable.
what

#4 ApEk   Members   -  Reputation: 439

Like
0Likes
Like

Posted 13 November 2012 - 11:03 AM

Hi, I am wondering if there is a function such as SDL_GetTicks() native to windows? I want to limit how often my update and draw methods execute inside my console application.


If you are able to use the new c++11 standard try to use the new chrono date and time utilities found here: http://en.cppreference.com/w/cpp/chrono
Note that using chrono is a little less than straightforward but here is a complete chrono timer class: http://codepad.org/FHkSQKiO

#5 radioteeth   Prime Members   -  Reputation: 921

Like
0Likes
Like

Posted 14 November 2012 - 10:00 AM

I've been using the C function clock(), which is a part of the C include time.h.. There is also a define in time.h 'CLOCKS_PER_SEC' which allows you to effectively do something like:
[source lang="cpp"]#include <time.h>float gettime(){ return (float)clock() / CLOCKS_PER_SEC;}[/source]
This has worked sufficiently well for the majority of my purposes, and being that it is a part of C itself it is as portable as portable can get.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS