SenorSnor
03-04-2007, 04:56 AM
I have an object consisting of some gluCylinders, and both the number of cylinders as the cylinders themselves grow over time. This is all called from glutIdleFunc. So basically glutIdleFunc calles a method that updates the object (lets it grow in size and complexity) and then it calls a method that draws the object to the screen.
Now as the object becomes more complex, it takes more time to update and draw the object. I have a double representing the age, and at the moment I just add 0.01 everytime the object is processed. I want the increment to be dependent on the time passed, so if say 1/100th of a second is passed, increment with 0.01, but if 7/100th of a second is passed, the age should be incremented with 0.07.
I've been trying stuff with time_t, keeping the time now and compare with that the next time and take the difference, but I'm not sure if it really works. I was wondering how this is usually done, and if people with more experience can give some hints?
Now as the object becomes more complex, it takes more time to update and draw the object. I have a double representing the age, and at the moment I just add 0.01 everytime the object is processed. I want the increment to be dependent on the time passed, so if say 1/100th of a second is passed, increment with 0.01, but if 7/100th of a second is passed, the age should be incremented with 0.07.
I've been trying stuff with time_t, keeping the time now and compare with that the next time and take the difference, but I'm not sure if it really works. I was wondering how this is usually done, and if people with more experience can give some hints?