Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Rotation of an object as a factor of time

This topic is 5942 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

I have a simple app where a cube spins on the screen around the y-axis, the problem is that if i run it fullscreen it rotates alot slower than if i have it run in a small window. I want the rotation to be a factor of time (rotate one degree a second, regardless of screensize). How it''s set up now my glutIdleFunc is my display function, so the screen is redrawn as much as possible and in there rotateFactor = rotationTime() (rotationTime() returns the number of microseconds in the current seconds divided by one million, so it''s a fraction instead of a whole number) which I thought would be enough, but apparently it isn''t. Any help would be appreciated, thanks. PS- One small thing, when the cube gets farther away from the camera it gets bigger instead of smaller, how can I fix this (I assume some glEnable() or other call will fix it, but I don''t know which))? Thanks.

Share this post

Link to post
Share on other sites
What you want to do is interpolate the rotation. To do this you need a way to check time that has elapsed. I reccomend using the sdl. it has a timer that and more.

so what you would do is, each frame check how many miliseconds have elapsed since the last frame. divide the number by 1000 and you have the seconds per frame. say your variable for secs per frame is spf and you want to rotate 90 degrees per second. then you would use spf*90 ase the amount you want to rotate.

also, if you want to know the fps, and display it. all you do is divide fps=1/spf;

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!