uint G_GetTime( void ){ struct timespec tv ; clock_gettime( CLOCK_MONOTONIC, &tv ) ; return tv.tv_nsec / 1000 ;}
I though that tv.tv_nsec records nano time so doesn't that mean you have to divide by 1000 to get milliseconds? Anyways, I've ran a little debug to output the time value and I get this:
time: 88
time: 22998
time: 125476
time: 245781
time: 388564
time: 567986
time: 805240
time: 1054080
time: 1322626
time: 1617701
etc..
I have another procedure that records the time initially, yet another procedure that returns the difference(hopefully in milliseconds) between the current time and the one saved. As you can see from above something is wrong and I have overlooked something. These are the other procedures:
// ---------------------------------------------------------------------------void G_SetState ( uint state ){ st_curr = state ; st_time = G_GetTime( ) ; st_timeLaps = 0 ;}// ---------------------------------------------------------------------------uint G_GetStateTime( void ){ st_timeLaps += ( G_GetTime( ) - st_time ) ; return st_timeLaps ;}
I'm so confused is to why it's not working... Can someone help me please?