1
0
Fork 0

Implimented a simple frame rate throttle.

Normally for smoothest frame rates you would configure to sync
to your monitor's vertical refresh signal.  This is card/platform
dependent ... for instance with Linux/Nvidia there is
an environment variable you can set to enable this feature.

However, if your monitor is refreshing at 60hz and you can't quite sustain
that with flightgear, you can get smoother frame rates by artificially
throttling yourself to 30hz.  Note that once you are about about 24fps, it
is *change* or inconsistancy in frame rate that leads to percieved jerkiness.

You want to do whole divisors of your monitor refresh rate, so if your
display is syncing at 75 hz, you might want to try throttling to 25 hz.
This commit is contained in:
curt 2003-06-02 16:35:36 +00:00
parent f30f40a2fb
commit 9c0c54ef6c
3 changed files with 18 additions and 13 deletions

View file

@ -1019,10 +1019,24 @@ static void fgMainLoop( void ) {
last_time_stamp.stamp();
first_time = false;
}
double throttle_hz = fgGetDouble("/sim/frame-rate-throttle-hz", 0.0);
if ( throttle_hz > 0.0 ) {
// simple frame rate throttle
double dt = 1000000.0 / throttle_hz;
current_time_stamp.stamp();
while ( current_time_stamp - last_time_stamp < dt ) {
current_time_stamp.stamp();
}
} else {
// run as fast as the app will go
current_time_stamp.stamp();
}
delta_time_sec = double(current_time_stamp - last_time_stamp) / 1000000.0;
if (clock_freeze->getBoolValue())
if ( clock_freeze->getBoolValue() ) {
delta_time_sec = 0;
}
last_time_stamp = current_time_stamp;
globals->inc_sim_time_sec( delta_time_sec );
SGAnimation::set_sim_time_sec( globals->get_sim_time_sec() );

View file

@ -406,23 +406,15 @@ bool FGNativeFDM::process() {
FGNetFDM2Props( &buf );
}
} else {
// double dt = 1000000.0 / 30.0;
// SGTimeStamp current; current.stamp();
int result;
result = io->read( (char *)(& buf), length );
while ( result == length ) {
if ( result == length ) {
SG_LOG( SG_IO, SG_DEBUG, " Success reading data." );
FGNetFDM2Props( &buf );
}
while ( result == length /* || current - last_time < dt */ ) {
result = io->read( (char *)(& buf), length );
if ( result == length ) {
SG_LOG( SG_IO, SG_DEBUG, " Success reading data." );
FGNetFDM2Props( &buf );
}
// current.stamp();
}
// last_time = current;
}
}

View file

@ -39,7 +39,6 @@ class FGNativeFDM : public FGProtocol, public FGInterface {
FGNetFDM buf;
int length;
SGTimeStamp last_time;
public: