Advertisement Jump to content
Sign in to follow this  

OpenGL Jumpy rotation animation?

This topic is 2264 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

// reset the ModelView Transform matrix

// Apply some transformations
glTranslatef(0.f, 0.f, -100.f);


// ********************** //
// ********************** //



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

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!