Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes #1685 where ofGetElapsedTimef() and ofGetElapsedTimeMicros() wr…

…ap after ~71 minutes
  • Loading branch information...
commit 4225e3e674f569c664a862c34523acc6d64b0f1b 1 parent 6f9c02f
@kylemcdonald kylemcdonald authored
View
20 libs/openFrameworks/utils/ofUtils.cpp
@@ -44,16 +44,16 @@
#endif
static bool enableDataPath = true;
-static unsigned long startTime = ofGetSystemTime(); // better at the first frame ?? (currently, there is some delay from static init, to running.
-static unsigned long startTimeMicros = ofGetSystemTimeMicros();
+static unsigned long long startTime = ofGetSystemTime(); // better at the first frame ?? (currently, there is some delay from static init, to running.
+static unsigned long long startTimeMicros = ofGetSystemTimeMicros();
//--------------------------------------
-unsigned long ofGetElapsedTimeMillis(){
+unsigned long long ofGetElapsedTimeMillis(){
return ofGetSystemTime() - startTime;
}
//--------------------------------------
-unsigned long ofGetElapsedTimeMicros(){
+unsigned long long ofGetElapsedTimeMicros(){
return ofGetSystemTimeMicros() - startTimeMicros;
}
@@ -75,11 +75,13 @@ void ofResetElapsedTimeCounter(){
* when subtracting an initial start time, unless the total time exceeds
* 32-bit, where the GLUT API return value is also overflowed.
*/
-unsigned long ofGetSystemTime( ) {
+unsigned long long ofGetSystemTime( ) {
#ifndef TARGET_WIN32
struct timeval now;
gettimeofday( &now, NULL );
- return now.tv_usec/1000 + now.tv_sec*1000;
+ return
+ (unsigned long long) now.tv_usec/1000 +
+ (unsigned long long) now.tv_sec*1000;
#else
#if defined(_WIN32_WCE)
return GetTickCount();
@@ -89,11 +91,13 @@ unsigned long ofGetSystemTime( ) {
#endif
}
-unsigned long ofGetSystemTimeMicros( ) {
+unsigned long long ofGetSystemTimeMicros( ) {
#ifndef TARGET_WIN32
struct timeval now;
gettimeofday( &now, NULL );
- return now.tv_usec + now.tv_sec*1000000;
+ return
+ (unsigned long long) now.tv_usec +
+ (unsigned long long) now.tv_sec*1000000;
#else
#if defined(_WIN32_WCE)
return GetTickCount()*1000;
View
8 libs/openFrameworks/utils/ofUtils.h
@@ -14,8 +14,8 @@ int ofNextPow2(int input);
void ofResetElapsedTimeCounter(); // this happens on the first frame
float ofGetElapsedTimef();
-unsigned long ofGetElapsedTimeMillis();
-unsigned long ofGetElapsedTimeMicros();
+unsigned long long ofGetElapsedTimeMillis();
+unsigned long long ofGetElapsedTimeMicros();
int ofGetFrameNum();
int ofGetSeconds();
@@ -25,8 +25,8 @@ int ofGetHours();
//number of seconds since 1970
unsigned int ofGetUnixTime();
-unsigned long ofGetSystemTime( ); // system time in milliseconds;
-unsigned long ofGetSystemTimeMicros( ); // system time in microseconds;
+unsigned long long ofGetSystemTime( ); // system time in milliseconds;
+unsigned long long ofGetSystemTimeMicros( ); // system time in microseconds;
//returns
string ofGetTimestampString();
Please sign in to comment.
Something went wrong with that request. Please try again.