Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

"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: 187

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   Members   -  Reputation: 1875

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.


#3 incertia   Crossbones+   -  Reputation: 522

Like
1Likes
Like

Posted 12 November 2012 - 09:43 PM

GetTickCount()
is another, but it's not very reliable.
Current project here

#4 ApEk   Members   -  Reputation: 271

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   Members   -  Reputation: 427

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