Add support for elapsed time and logging.
This commit is contained in:
parent
d23c674846
commit
0d3b0f27ba
3 changed files with 26 additions and 31 deletions
|
@ -38,11 +38,13 @@ FGGlobals *globals;
|
|||
|
||||
// Constructor
|
||||
FGGlobals::FGGlobals() :
|
||||
elapsed_time_ms(0L),
|
||||
#if defined(FX) && defined(XMESA)
|
||||
fullscreen( true ),
|
||||
#endif
|
||||
warp( 0 ),
|
||||
warp_delta( 0 ),
|
||||
logger(0),
|
||||
props(new SGPropertyNode),
|
||||
initial_state(0),
|
||||
commands(new SGCommandMgr)
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef vector<string> string_list;
|
|||
|
||||
|
||||
// Forward declarations
|
||||
class FGLogger;
|
||||
class FGEnvironmentMgr;
|
||||
class FGEnvironment;
|
||||
class FGControls;
|
||||
|
@ -58,6 +59,9 @@ class FGGlobals {
|
|||
|
||||
private:
|
||||
|
||||
// Number of milliseconds elapsed since the start of the program.
|
||||
long elapsed_time_ms;
|
||||
|
||||
// Root of FlightGear data tree
|
||||
string fg_root;
|
||||
|
||||
|
@ -82,6 +86,9 @@ private:
|
|||
// to make time progress faster than normal (or even run in reverse.)
|
||||
long int warp_delta;
|
||||
|
||||
// Logger
|
||||
FGLogger * logger;
|
||||
|
||||
// Time structure
|
||||
SGTime *time_params;
|
||||
|
||||
|
@ -130,6 +137,9 @@ public:
|
|||
FGGlobals();
|
||||
~FGGlobals();
|
||||
|
||||
inline long get_elapsed_time_ms () const { return elapsed_time_ms; }
|
||||
inline void set_elapsed_time_ms (long t) { elapsed_time_ms = t; }
|
||||
|
||||
inline const string &get_fg_root () const { return fg_root; }
|
||||
inline void set_fg_root (const string &root) { fg_root = root; }
|
||||
|
||||
|
@ -156,6 +166,9 @@ public:
|
|||
inline void set_warp_delta( long int d ) { warp_delta = d; }
|
||||
inline void inc_warp_delta( long int d ) { warp_delta += d; }
|
||||
|
||||
inline FGLogger * get_logger () { return logger; }
|
||||
inline void set_logger (FGLogger * l) { logger = l; }
|
||||
|
||||
inline SGTime *get_time_params() const { return time_params; }
|
||||
inline void set_time_params( SGTime *t ) { time_params = t; }
|
||||
|
||||
|
|
|
@ -152,6 +152,7 @@ sgVec3 rway_ols;
|
|||
#include "splash.hxx"
|
||||
#include "viewmgr.hxx"
|
||||
#include "options.hxx"
|
||||
#include "logger.hxx"
|
||||
#include "model.hxx"
|
||||
|
||||
#ifdef macintosh
|
||||
|
@ -225,6 +226,9 @@ ssgSimpleState *default_state;
|
|||
ssgSimpleState *hud_and_panel;
|
||||
ssgSimpleState *menus;
|
||||
|
||||
SGTimeStamp start_time_stamp;
|
||||
SGTimeStamp current_time_stamp;
|
||||
|
||||
void fgBuildRenderStates( void ) {
|
||||
default_state = new ssgSimpleState;
|
||||
default_state->ref();
|
||||
|
@ -423,22 +427,19 @@ void fgRenderFrame( void ) {
|
|||
if ( fgGetBool("/sim/startup/splash-screen") ) {
|
||||
fgSplashUpdate(0.0);
|
||||
}
|
||||
start_time_stamp.stamp(); // Keep resetting the start time
|
||||
} else {
|
||||
// idle_state is now 1000 meaning we've finished all our
|
||||
// initializations and are running the main loop, so this will
|
||||
// now work without seg faulting the system.
|
||||
|
||||
// printf("Ground = %.2f Altitude = %.2f\n", scenery.get_cur_elev(),
|
||||
// FG_Altitude * SG_FEET_TO_METER);
|
||||
|
||||
// this is just a temporary hack, to make me understand Pui
|
||||
// timerText -> setLabel (ctime (&t->cur_time));
|
||||
// end of hack
|
||||
// Update the elapsed time.
|
||||
current_time_stamp.stamp();
|
||||
globals->set_elapsed_time_ms((current_time_stamp - start_time_stamp)
|
||||
/ 1000L);
|
||||
|
||||
// calculate our current position in cartesian space
|
||||
scenery.set_center( scenery.get_next_center() );
|
||||
// printf("scenery center = %.2f %.2f %.2f\n", scenery.center.x(),
|
||||
// scenery.center.y(), scenery.center.z());
|
||||
|
||||
FGViewerRPH *pilot_view =
|
||||
(FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
|
||||
|
@ -485,29 +486,6 @@ void fgRenderFrame( void ) {
|
|||
chase_view->set_view_forward( pilot_view->get_view_pos() );
|
||||
chase_view->set_view_up( wup );
|
||||
|
||||
#if 0
|
||||
sgMat4 rph;
|
||||
sgCopyMat4( rph, pilot_view->get_VIEW() );
|
||||
cout << "RPH Matrix = " << endl;
|
||||
int i, j;
|
||||
for ( i = 0; i < 4; i++ ) {
|
||||
for ( j = 0; j < 4; j++ ) {
|
||||
printf("%10.4f ", rph[i][j]);
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
sgMat4 la;
|
||||
sgCopyMat4( la, chase_view->get_VIEW() );
|
||||
cout << "LookAt Matrix = " << endl;
|
||||
for ( i = 0; i < 4; i++ ) {
|
||||
for ( j = 0; j < 4; j++ ) {
|
||||
printf("%10.4f ", la[i][j]);
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// update view port
|
||||
fgReshape( fgGetInt("/sim/startup/xsize"),
|
||||
fgGetInt("/sim/startup/ysize") );
|
||||
|
@ -810,6 +788,8 @@ void fgRenderFrame( void ) {
|
|||
// glDisable ( GL_BLEND ) ;
|
||||
|
||||
// glEnable( GL_FOG );
|
||||
|
||||
globals->get_logger()->update(0); // FIXME: use real dt
|
||||
}
|
||||
|
||||
glutSwapBuffers();
|
||||
|
|
Loading…
Reference in a new issue