Sign in to follow this  
ashwini_rt

time problem??

Recommended Posts

hii eveyone.. I hv drawn a Beam which must complete it's rotation n 8sec..to with that i hav used the sec value of sys time..so that the beam completes 45deg in 1sec..Thus,makes 1 complete rotation (360deg) in 8sec.. but the problem is it looks like clock tick..I wana make it as sweep how can i do that?? or another option s ther any function to acess the mili second value of time so that my beam can make 10deg rotation in each 20mSec ?? so plz..can any 1 help me out..?? here s my snippet of code........... void display(void) { time(<ime); // Get time newtime = localtime(<ime); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f( 1.0, 0.0, 1.0); bitmap_output(-r_max,-r_max, asctime(newtime),GLUT_BITMAP_TIMES_ROMAN_24); glPushMatrix(); glRotatef( 180, 1.0, 0.0, 0.0); glPushMatrix(); glRotatef( (360/8) * (newtime->tm_sec), 0.0, 0.0, 1.0); drawBeam(0.0,0.0,0.0, 12); glPopMatrix(); glPopMatrix(); glutSwapBuffers() ; }

Share this post


Link to post
Share on other sites
If you are using GLUT (I assumed as you used glutSwapBuffers) use glutGet(GLUT_ELAPSED_TIME) to get the time in miliseconds.

You can then multiply the time by 45 degrees and divide by 1000 to keep it in scale.

Hope that helps

Share this post


Link to post
Share on other sites
hii...
I've tried what u hav said i,e i used getElapsedtime function..but the problem s i wana make the movement of beam aa a continueous sweep but its looks a if a clock tics for every 45deg how can i do that can u plzz help...

Share this post


Link to post
Share on other sites
Quote:
I've tried what u hav said i,e i used getElapsedtime function..but the problem s i wana make the movement of beam aa a continueous sweep but its looks a if a clock tics for every 45deg how can i do that can u plzz help...
Post your revised code (be sure to use [source] tags).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this