objects rotating really fast

Started by
2 comments, last by eSCHEn 18 years, 9 months ago
something weird is happening :) when i run the lessons with rotating objects on my main computer they spin really fast while when i run it on my other computer wich got less fast hardware it rotates smoothly and 'slowly' anyone knows howcome ? :)
Advertisement
The variable that controls the rotation is updated every time a frame is rendered. If you move 0.1f per frame then at 100 FPS you move 100 * 0.1f = 10 rotations a second, if you can only manage 20 FPS then you'll move at 20 * 0.1f = 2 rotations a second. If you move too fast then you'll get jerky movement, simple as that :)

If you're just learning then it's nothing to worry about at the moment but if you want to 'fix' this then you need to time how long a frame takes to render and scale the movement by that. A different solution would be to separate the updating of the variable from its rendering and use a fixed update frequency.

Some timer code in Lesson 21

Hope that helps :)
--
Cheers,
Darren Clark
thx ^^

now i understand why its rotating fast :)

though im only learning at the moment so then ill just wait :)

No problems. Welcome to NeHe and the wonderful world of OpenGL :D

I'll point you over to the forums FAQ, it's got some excellent tips and shows you the correct way to post code segments, which as you're learning will be helpful I'd imagine ;)
--
Cheers,
Darren Clark

This topic is closed to new replies.

Advertisement