Rotating speed based on CPU

Hi Guys,

does anybody of you know if there is way to make the rotating of objects (cubes for example) the same speed on each CPU ?

I tested a small thing I wrote but on a CPU 1.2ghz it’s ofcourse slow and on my 3200+ it’s very fast.

Is there a way to detect the CPU speed so I can change the rotating speed based on CPU ?

All help is welcome…


I don’t understand why you can’t just go with time-based animation as everyone does. In today’s pre-emptive world, the method I figure out from what you say is error prone (interrupts and multiprogramming).

Anyway, there’s no easy way to poll for CPU speed.
In win32 you can look at the registry (I don’t have the registry key here now) while on linux you can look at /proc/cpuinfo.
This gives you the speed in Mhz.
Another way is to use the performance counter, but this is also difficult to implement in a safe matter.
Anyway, for variable-clock CPUs, everything is much painful.
I just hope not a single CPU decides to lower CPU clock while an intensive app is running - this seems a rather good assumption.


what I actually ment is indeed if there is a way to have time based animation.

For example, I have a cube rotating on my laptop with a speed around the x-axis of 0.130f. When I run this on my main pc, the cube rotates as hell :slight_smile:

As I posted it here I’m just a rookie :slight_smile:
I want to let the cubes rotate on each pc at the same speed, meaning it has to look if they rotate at the same speed and from what I learned until now is the only possibility to decrease the 0.130f to 0.050f to let the cube rotate on my fast pc the same.

Maybe there are other solutions but until now I did not figured them out…

I hope it’s understandable now…


Decide how far you want the cube to rotate in a second, lets say 10 degrees
Now every frame poll the current time using your favorite function, lets use timeGetTime. This returns the time in milleseconds. If we store the previous frame’s time we can get
deltaT = CurrentTime-OldTime
the time for one frame. If we want the cube rotating at 10degrees/s we need to rotate it by
10*(deltaT/1000) in a given frame.

Thanks Chowe,

I’ll give that a try.