Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix ofGetElapsedTimef() with unsigned long long #1688

Merged
merged 2 commits into from

2 participants

@kylemcdonald
Owner

this branch fixes the bug by using unsigned long long everywhere. i've tested both of these by manually setting my clock and moving time around.

@kylemcdonald kylemcdonald merged commit 4cd8e09 into from
@cindyloo

ah, thanks Kyle! I am having this problem now. will update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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();
Something went wrong with that request. Please try again.