get current time during runtime...

Started by
16 comments, last by songho 15 years, 4 months ago
hii... how to get current time during runtime... i use this command in opengl graphic function.,. GLdouble timme; timme=glutGet(GLUT_ELAPSED_TIME); cout<< "time = " << timme * 0.001f <<endl; so the output is in -ve values......what the meaning of that....i want to get actual time in millisecond or seconds... plzzz suggest me....thanksss.
Advertisement
Clarify:
Seconds/milliseconds since power on?
Seconds/milliseconds since GLUT initialization?
Seconds/milliseconds since Jan 1, 1970?
Current local time?
glutGet(GLUT_ELAPSED_TIME) returns the number of milliseconds since glutInit was called. If you want the current local time, you can use a platform-specific function, or maybe time and localtime in the C-runtime library (which is at least somewhat portable).
Seconds/milliseconds since GLUT initialization...

means that i want to draw graph between time and position of some object in real time simulation...

so time will be changed during time...and position of some object also...
Quote:Original post by luckyyyyyy
Seconds/milliseconds since GLUT initialization...


Yep, and that's what glutGet(GLUT_ELAPSED_TIME) should do.

Sorry, I'm not sure what the problem is? I don't know what "so the output is in -ve values" means (I guess English is not your first language :)
negative value means ......like that...

-1.245
-1.245
-1.678
-1.932
2.345
8.564
-0.345
-0.345


u can see in that pic...


124236534653465666.png
[img=http://xs234.xs.to/xs234/08502/124236534653465666.png]
time in negative values is confusing...it should be positive i think...



Oh I see... yeah, that doesn't look right. I don't actually use OpenGL myself so I'll leave this to someone with more knowledge than me :-) perhaps you could post the full code you're using?
glutGet() actually returns an integer value. Please change the variable from double to int.
int timme;
timme=glutGet(GLUT_ELAPSED_TIME);
cout<<"time = "<<timme<<endl;


i changed from double to int...

now the result is

Free Image Hosting


what the meaning of negative values...

and all are in 4 digits....sooooooo if i wana in millisecond then what i should do...

plzzz explain,,.,.
I quickly tested glutGet(GLUT_ELAPSED_TIME) on my system, and it works fine.

But, I notice that your outputs are decreasing. Does GLUT initialized properly? Or, your GLUT lib may be broken.

This topic is closed to new replies.

Advertisement