Archived

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

Xolution

Rotation of an object as a factor of time

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