Jump to content

  • Log In with Google      Sign In   
  • Create Account

Jumpy rotation animation?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Dezachu   Members   -  Reputation: 386

Like
0Likes
Like

Posted 10 November 2012 - 07:31 PM

Hey guys, bit of a noob with OpenGL (Only just started utilising it on my course!). C++.

Got this:

[source lang="cpp"]if((float)Clock.GetElapsedTime()>REFRESH_RATE){ // Clear colour and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // reset the ModelView Transform matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Apply some transformations glTranslatef(0.f, 0.f, -100.f); //glRotatef(15.f,1.f,0.f,0.f); glRotatef(i,0.f,1.f,0.f); glRotatef(i-15,0.f,0.f,1.f); glRotatef(i+15,1.f,0.f,0.f); // ********************** // drawCylinder(20,20,40); // ********************** // i++; Clock.Reset(); }[/source]

The drawCylinder uses to TRIANGLE_FAN objects and then QUAD_STRIP's, all created via a for loop. The parameters passed in are radius, numberOfSides and height.

i++ is a float declared at the beginning of the program: float i = 30; (I know it should be called f for float, but more confusion to be made there that I was better off avoiding).


When I run the program, the animation is very jumpy as it rotates. Any clues as to why? Cheers :)


EDIT: Dropping the framrate from 0.03 to 0.01 has improved it somewhat. Still, I'd imagine the animation would be more stuttery than jumpy. The animation basically flashed back to the previous frame every so often, looked a bit daft.

Edited by Dezachu, 10 November 2012 - 07:34 PM.

Studying BSc Computer Games Programming @ De Montfort University, Leicester.

Completed a placement as a Junior Programmer at Exient Ltd in Oxford/Valletta, Malta


Sponsor:

#2 Nyssa   Members   -  Reputation: 426

Like
0Likes
Like

Posted 10 November 2012 - 10:30 PM

If you remove the following line does it run smooth? :
[source lang="java"]if((float)Clock.GetElapsedTime()>REFRESH_RATE)[/source]
If so then it might be a problem with your clock rather than a problem with opengGL.

Edited by Jaroy, 10 November 2012 - 10:39 PM.


#3 C0lumbo   Crossbones+   -  Reputation: 2269

Like
0Likes
Like

Posted 11 November 2012 - 08:13 AM

I agree, when your if((float)Clock.GetElapsedTime()>REFRESH_RATE) test fails, then you're doing a frame without even a glClear, so the frame buffer displayed is full of arbitrary junk. Usually the arbitrary junk it's full of is frame n-2 or frame n-3 (where the current frame is frame n), hence you're seeing your animation jump backwards.

I suggest that only i++; and Clock.Reset(); should be inside your if statement.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS