1
0
Fork 0

Add support for elapsed time and logging.

This commit is contained in:
david 2002-03-12 16:30:27 +00:00
parent d23c674846
commit 0d3b0f27ba
3 changed files with 26 additions and 31 deletions

View file

@ -38,11 +38,13 @@ FGGlobals *globals;
// Constructor // Constructor
FGGlobals::FGGlobals() : FGGlobals::FGGlobals() :
elapsed_time_ms(0L),
#if defined(FX) && defined(XMESA) #if defined(FX) && defined(XMESA)
fullscreen( true ), fullscreen( true ),
#endif #endif
warp( 0 ), warp( 0 ),
warp_delta( 0 ), warp_delta( 0 ),
logger(0),
props(new SGPropertyNode), props(new SGPropertyNode),
initial_state(0), initial_state(0),
commands(new SGCommandMgr) commands(new SGCommandMgr)

View file

@ -44,6 +44,7 @@ typedef vector<string> string_list;
// Forward declarations // Forward declarations
class FGLogger;
class FGEnvironmentMgr; class FGEnvironmentMgr;
class FGEnvironment; class FGEnvironment;
class FGControls; class FGControls;
@ -58,6 +59,9 @@ class FGGlobals {
private: private:
// Number of milliseconds elapsed since the start of the program.
long elapsed_time_ms;
// Root of FlightGear data tree // Root of FlightGear data tree
string fg_root; string fg_root;
@ -82,6 +86,9 @@ private:
// to make time progress faster than normal (or even run in reverse.) // to make time progress faster than normal (or even run in reverse.)
long int warp_delta; long int warp_delta;
// Logger
FGLogger * logger;
// Time structure // Time structure
SGTime *time_params; SGTime *time_params;
@ -130,6 +137,9 @@ public:
FGGlobals(); FGGlobals();
~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 const string &get_fg_root () const { return fg_root; }
inline void set_fg_root (const string &root) { fg_root = 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 set_warp_delta( long int d ) { warp_delta = d; }
inline void inc_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 SGTime *get_time_params() const { return time_params; }
inline void set_time_params( SGTime *t ) { time_params = t; } inline void set_time_params( SGTime *t ) { time_params = t; }

View file

@ -152,6 +152,7 @@ sgVec3 rway_ols;
#include "splash.hxx" #include "splash.hxx"
#include "viewmgr.hxx" #include "viewmgr.hxx"
#include "options.hxx" #include "options.hxx"
#include "logger.hxx"
#include "model.hxx" #include "model.hxx"
#ifdef macintosh #ifdef macintosh
@ -225,6 +226,9 @@ ssgSimpleState *default_state;
ssgSimpleState *hud_and_panel; ssgSimpleState *hud_and_panel;
ssgSimpleState *menus; ssgSimpleState *menus;
SGTimeStamp start_time_stamp;
SGTimeStamp current_time_stamp;
void fgBuildRenderStates( void ) { void fgBuildRenderStates( void ) {
default_state = new ssgSimpleState; default_state = new ssgSimpleState;
default_state->ref(); default_state->ref();
@ -423,22 +427,19 @@ void fgRenderFrame( void ) {
if ( fgGetBool("/sim/startup/splash-screen") ) { if ( fgGetBool("/sim/startup/splash-screen") ) {
fgSplashUpdate(0.0); fgSplashUpdate(0.0);
} }
start_time_stamp.stamp(); // Keep resetting the start time
} else { } else {
// idle_state is now 1000 meaning we've finished all our // idle_state is now 1000 meaning we've finished all our
// initializations and are running the main loop, so this will // initializations and are running the main loop, so this will
// now work without seg faulting the system. // now work without seg faulting the system.
// printf("Ground = %.2f Altitude = %.2f\n", scenery.get_cur_elev(), // Update the elapsed time.
// FG_Altitude * SG_FEET_TO_METER); current_time_stamp.stamp();
globals->set_elapsed_time_ms((current_time_stamp - start_time_stamp)
// this is just a temporary hack, to make me understand Pui / 1000L);
// timerText -> setLabel (ctime (&t->cur_time));
// end of hack
// calculate our current position in cartesian space // calculate our current position in cartesian space
scenery.set_center( scenery.get_next_center() ); 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 *pilot_view =
(FGViewerRPH *)globals->get_viewmgr()->get_view( 0 ); (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_forward( pilot_view->get_view_pos() );
chase_view->set_view_up( wup ); 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 // update view port
fgReshape( fgGetInt("/sim/startup/xsize"), fgReshape( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") ); fgGetInt("/sim/startup/ysize") );
@ -810,6 +788,8 @@ void fgRenderFrame( void ) {
// glDisable ( GL_BLEND ) ; // glDisable ( GL_BLEND ) ;
// glEnable( GL_FOG ); // glEnable( GL_FOG );
globals->get_logger()->update(0); // FIXME: use real dt
} }
glutSwapBuffers(); glutSwapBuffers();