Hi,

I need to control the frame rate of my viewers. For the moment, I do:

osg::Timer_t start, end;
OpenThreads::Condition condition;
OpenThreads::Mutex mutex;
mutex.lock();

double targetFrameDuration = 1000.0 / targetFrameRate;

while (! _impl->viewer->done() && !_impl->stopSimulation)
{
  start = osg::Timer::instance()->tick();
     frame();
  end = osg::Timer::instance()->tick();
double duration = osg::Timer::instance()->delta_m(start, end);
  if (targetFrameDuration > duration)
  {
     unsigned long int remaining = targetFrameDuration - duration;
     condition.wait(&mutex, remaining);
  }
}

But it isn't very precise for very high or very or real frame rates.

Any suggestion ?


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to