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.
"Frames" per second in Win32 console application
Started by dAND3h, Nov 12 2012 04:48 PM
4 replies to this topic
#2 Members - Reputation: 1871
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...
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.
#4 Members - Reputation: 270
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 Members - Reputation: 423
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.
[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.






