]> git.mxchange.org Git - flightgear.git/commitdiff
Moved fov and win_ration from FGOptions to FGViewer so we can control these
authorcurt <curt>
Wed, 1 Nov 2000 23:27:32 +0000 (23:27 +0000)
committercurt <curt>
Wed, 1 Nov 2000 23:27:32 +0000 (23:27 +0000)
on a per view basis.
Fixed some compile warnings in Main/*.cxx

13 files changed:
src/Cockpit/cockpit.cxx
src/Cockpit/panel.cxx
src/Main/Makefile.am
src/Main/bfi.cxx
src/Main/fg_init.cxx
src/Main/keyboard.cxx
src/Main/main.cxx
src/Main/options.cxx
src/Main/options.hxx
src/Main/save.cxx
src/Main/viewer.cxx
src/Main/viewer.hxx
src/Main/viewer_lookat.cxx

index b338a82a01a61c4f1c274515a04dd2864a9520f1..1a608409e11b5b183ed1a3210785732fa7195960 100644 (file)
@@ -235,7 +235,7 @@ float get_frame_rate( void )
 
 float get_fov( void )
 {
-    float fov = globals->get_options()->get_fov(); 
+    float fov = globals->get_current_view()->get_fov(); 
     return (fov);
 }
 
index 95de80c6ce5f61d976364a23cdded723f09a3342..01bf36cdb974a0f42b428f9de0c003eef3ecd7cb 100644 (file)
@@ -45,7 +45,6 @@ bool
 fgPanelVisible ()
 {
   return ((globals->get_options()->get_panel_status()) &&
-         (globals->get_options()->get_view_mode() == FGOptions::FG_VIEW_PILOT) &&
          (globals->get_current_view()->get_view_offset() == 0.0));
 }
 
index 5a6fb296726b8bbfa84f95b184688a9f60d1026e..a72bd935c27e4a0294d1da211d77480f1c1ea27d 100644 (file)
@@ -20,7 +20,7 @@ NETWORK_LIBS = \
 endif
 
 if OLD_AUTOMAKE
-CXXFLAGS += -DPKGLIBDIR=\"$(pkglibdir)\"
+# nothing CXXFLAGS += -DPKGLIBDIR=\"$(pkglibdir)\"
 else
 AM_CXXFLAGS = -DPKGLIBDIR=\"$(pkglibdir)\"
 endif
index 93a12c98bbd1e49d89628f56e78b10660e0a053a..85a4e2dfa200d3f6062452fe011206fa07b277cc 100644 (file)
@@ -107,8 +107,8 @@ reinit ()
   double apAltitude = FGBFI::getAPAltitude();
   const string &targetAirport = FGBFI::getTargetAirport();
   bool gpsLock = FGBFI::getGPSLock();
-  double gpsLatitude = FGBFI::getGPSTargetLatitude();
-  double gpsLongitude = FGBFI::getGPSTargetLongitude();
+  // double gpsLatitude = FGBFI::getGPSTargetLatitude();
+  // double gpsLongitude = FGBFI::getGPSTargetLongitude();
 
   FGBFI::setTargetAirport("");
   cout << "Target airport is " << globals->get_options()->get_airport_id() << endl;
@@ -753,6 +753,8 @@ FGBFI::getEGT ()
 {
   if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
       return current_aircraft.fdm_state->get_engine(0)->get_EGT();
+  } else {
+      return 0.0;
   }
 }
 
@@ -765,6 +767,8 @@ FGBFI::getCHT ()
 {
   if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
       return current_aircraft.fdm_state->get_engine(0)->get_CHT();
+  } else {
+      return 0.0;
   }
 }
 
@@ -777,6 +781,8 @@ FGBFI::getMP ()
 {
   if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
       return current_aircraft.fdm_state->get_engine(0)->get_Manifold_Pressure();
+  } else {
+      return 0.0;
   }
 }
 
index cbc8489894e116d09897cd7562b71af2a30c43c2..dd571f349144eae1b8e6958b4b1d5542d2e205ac 100644 (file)
@@ -221,7 +221,7 @@ bool fgSetPosFromAirportID( const string& id ) {
 bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
     FGRunway r;
     FGRunway found_r;
-    double found_dir;
+    double found_dir = 0.0;
 
     if ( id.length() ) {
        // set initial position from runway and heading
@@ -564,10 +564,12 @@ bool fgInitSubsystems( void ) {
                                                   &fgEVENT_MGR::PrintStats),
                            fgEVENT::FG_EVENT_READY, 60000 );
 
-    // Initialize win ratio parameters
-    globals->get_options()->set_win_ratio( globals->get_options()->get_xsize() /
-                                          globals->get_options()->get_ysize()
-                                          );
+    // Initialize win_ratio parameters
+    for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
+       globals->get_viewmgr()->get_view(i)->
+           set_win_ratio( globals->get_options()->get_xsize() /
+                          globals->get_options()->get_ysize() );
+    }
 
     // Initialize pilot view
     FGViewerRPH *pilot_view =
index 22dbc9593b38ecc4e025d2c8588324ec1941333c..b9a0dd4c69cf56d58921e95337a638ab29a76d44 100644 (file)
@@ -213,12 +213,12 @@ void GLUTkey(unsigned char k, int x, int y) {
 #endif
            return;
        case 88: // X key
-           fov = globals->get_options()->get_fov();
+           fov = globals->get_current_view()->get_fov();
            fov *= 1.05;
            if ( fov > FG_FOV_MAX ) {
                fov = FG_FOV_MAX;
            }
-           globals->get_options()->set_fov(fov);
+           globals->get_current_view()->set_fov(fov);
            // v->force_update_fov_math();
            return;
        case 90: // Z key
@@ -375,12 +375,12 @@ void GLUTkey(unsigned char k, int x, int y) {
                       globals->get_options()->get_ysize() );
            return;
        case 120: // x key
-           fov = globals->get_options()->get_fov();
+           fov = globals->get_current_view()->get_fov();
            fov /= 1.05;
            if ( fov < FG_FOV_MIN ) {
                fov = FG_FOV_MIN;
            }
-           globals->get_options()->set_fov(fov);
+           globals->get_current_view()->set_fov(fov);
            // v->force_update_fov_math();
            return;
        case 122: // z key
@@ -519,7 +519,7 @@ void GLUTspecialkey(int k, int x, int y) {
        switch (k) {
        case GLUT_KEY_F2: // F2 Reload Tile Cache...
            {
-               bool freeze;
+               bool freeze = globals->get_freeze();
                FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
                if ( !freeze ) 
                    globals->set_freeze( true );
index ea6659760b050691f0088c97e660b6a4d8c2e836..edfe877151c8d3c5a4eafca0057633573f0811c7 100644 (file)
@@ -387,6 +387,12 @@ void fgRenderFrame( void ) {
 #endif
 
        // update view port
+       fgReshape( globals->get_options()->get_xsize(),
+                  globals->get_options()->get_ysize() );
+
+#if 0
+       // swing and a miss
+
        if ( ! fgPanelVisible() ) {
            xglViewport( 0, 0 ,
                         (GLint)(globals->get_options()->get_xsize()),
@@ -401,6 +407,7 @@ void fgRenderFrame( void ) {
                        (GLint)(globals->get_options()->get_xsize()),
                        (GLint)(view_h) );
        }
+#endif
 
        // set the sun position
        glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
@@ -554,8 +561,8 @@ void fgRenderFrame( void ) {
 
        // glMatrixMode( GL_PROJECTION );
        // glLoadIdentity();
-       float fov = globals->get_options()->get_fov();
-       ssgSetFOV(fov, fov * globals->get_options()->get_win_ratio());
+       float fov = globals->get_current_view()->get_fov();
+       ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
 
        double agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
            - scenery.cur_elev;
@@ -1165,16 +1172,27 @@ static void fgIdleFunction ( void ) {
 // options.cxx needs to see this for toggle_panel()
 // Handle new window size or exposure
 void fgReshape( int width, int height ) {
+    // for all views
+    for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
+       if ( ! fgPanelVisible() || idle_state != 1000 ) {
+           globals->get_viewmgr()->get_view(i)->
+               set_win_ratio( (float)height / (float)width );
+       } else {
+           int view_h =
+               int((current_panel->getViewHeight() -
+                    current_panel->getYOffset())
+                   * (height / 768.0)) + 1;
+           globals->get_viewmgr()->get_view(i)->
+               set_win_ratio( (float)view_h / (float)width );
+       }
+    }
+
     if ( ! fgPanelVisible() || idle_state != 1000 ) {
-       globals->get_options()->set_win_ratio( (float)height /
-                                              (float)width );
        glViewport(0, 0 , (GLint)(width), (GLint)(height) );
     } else {
         int view_h =
-         int((current_panel->getViewHeight() - current_panel->getYOffset())
-             * (height / 768.0)) + 1;
-       globals->get_options()->set_win_ratio( (float)view_h /
-                                              (float)width );
+           int((current_panel->getViewHeight() - current_panel->getYOffset())
+               * (height / 768.0)) + 1;
        glViewport(0, (GLint)(height - view_h),
                   (GLint)(width), (GLint)(view_h) );
     }
@@ -1182,8 +1200,8 @@ void fgReshape( int width, int height ) {
     globals->get_options()->set_xsize( width );
     globals->get_options()->set_ysize( height );
 
-    float fov = globals->get_options()->get_fov();
-    ssgSetFOV(fov, fov * globals->get_options()->get_win_ratio());
+    float fov = globals->get_current_view()->get_fov();
+    ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
 
     fgHUDReshape();
 }
@@ -1545,8 +1563,8 @@ int main( int argc, char **argv ) {
     sgMat4 tux_matrix;
     float h_rot =
       current_properties.getFloatValue("/sim/model/h-rotation", 0.0);
-    float p_rot =
-      current_properties.getFloatValue("/sim/model/p-rotation", 0.0);
+    /* float p_rot =
+      current_properties.getFloatValue("/sim/model/p-rotation", 0.0); */
     float r_rot =
       current_properties.getFloatValue("/sim/model/r-rotation", 0.0);
     sgMakeRotMat4(tux_matrix, h_rot, h_rot, r_rot);
index d14df1a1fd93cea52167ed670caae88e181486b6..4cb994fb8fe8ec1ea48337d5e80b65abb898edcf 100644 (file)
@@ -180,7 +180,6 @@ FGOptions::FGOptions() :
     fog(FG_FOG_NICEST),  // nicest
     clouds(true),
     clouds_asl(5000*FEET_TO_METER),
-    fov(55.0),
     fullscreen(0),
     shading(1),
     skyblend(1),
@@ -547,9 +546,11 @@ FGOptions::parse_fov( const string& arg ) {
     if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
     if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
 
+    globals->get_current_view()->set_fov( fov );
+
     // printf("parse_fov(): result = %.4f\n", fov);
 
-    return(fov);
+    return fov;
 }
 
 
@@ -670,7 +671,6 @@ int FGOptions::parse_option( const string& arg ) {
        current_properties.setBoolValue("/sim/panel/visibility", true);
        if ( current_panel != NULL )
            current_panel->setVisibility(true);
-       // fov *= 0.4232; /* NO!!! */
     } else if ( arg == "--disable-sound" ) {
        sound = false;
     } else if ( arg == "--enable-sound" ) {
@@ -798,7 +798,7 @@ int FGOptions::parse_option( const string& arg ) {
            clouds_asl = atof( arg.substr(13) );
        }
     } else if ( arg.find( "--fov=" ) != string::npos ) {
-       fov = parse_fov( arg.substr(6) );
+       parse_fov( arg.substr(6) );
     } else if ( arg == "--disable-fullscreen" ) {
        fullscreen = false;     
     } else if ( arg== "--enable-fullscreen") {
index 9a6eb41a78e6637aa33eedf1b75e6e88144a441b..d38e9ae655f2b0ed143748f60ac0a26711820d53 100644 (file)
@@ -56,8 +56,6 @@ FG_USING_STD(vector);
 FG_USING_STD(string);
 
 #define NEW_DEFAULT_MODEL_HZ 120
-#define FG_FOV_MIN 0.1
-#define FG_FOV_MAX 179.9
 
 
 class FGOptions {
@@ -186,14 +184,12 @@ private:
     fgFogKind fog;      // Fog nicest/fastest/disabled
     bool clouds;        // Enable clouds
     double clouds_asl;  // Cloud layer height above sea level
-    double fov;         // Field of View
     bool fullscreen;    // Full screen mode enabled/disabled
     int shading;        // shading method, 0 = Flat, 1 = Smooth
     bool skyblend;      // Blend sky to haze (using polygons) or just clear
     bool textures;      // Textures enabled/disabled
     bool wireframe;     // Wireframe mode enabled/disabled
     int xsize, ysize;   // window size derived from geometry string
-    double win_ratio;  // ratio of x and y fov's; fov(y) = fov(x) * win_ratio
     int bpp;            // bits per pixel
     fgViewMode view_mode; // view mode
     double default_view_offset;        // default forward view offset (for use by
@@ -296,7 +292,6 @@ public:
     inline fgFogKind get_fog() const { return fog; }
     inline bool get_clouds() const { return clouds; }
     inline double get_clouds_asl() const { return clouds_asl; }
-    inline double get_fov() const { return fov; }
     inline bool get_fullscreen() const { return fullscreen; }
     inline int get_shading() const { return shading; }
     inline bool get_skyblend() const { return skyblend; }
@@ -304,7 +299,6 @@ public:
     inline bool get_wireframe() const { return wireframe; }
     inline int get_xsize() const { return xsize; }
     inline int get_ysize() const { return ysize; }
-    inline double get_win_ratio() const { return win_ratio; }
     inline int get_bpp() const { return bpp; }
     inline fgViewMode get_view_mode() const { return view_mode; }
     inline double get_default_view_offset() const {
@@ -359,7 +353,6 @@ public:
     inline void set_fog (fgFogKind value) { fog = value; }
     inline void set_clouds( bool value ) { clouds = value; }
     inline void set_clouds_asl( double value ) { clouds_asl = value; }
-    inline void set_fov( double amount ) { fov = amount; }
     inline void set_fullscreen (bool value) { fullscreen = value; }
     inline void set_shading (int value) { shading = value; }
     inline void set_skyblend (bool value) { skyblend = value; }
@@ -379,7 +372,6 @@ public:
     void toggle_panel();
     inline void set_xsize( int x ) { xsize = x; }
     inline void set_ysize( int y ) { ysize = y; }
-    inline void set_win_ratio( double r ) { win_ratio = r; }
     inline void set_view_mode (fgViewMode value) { view_mode = value; }
     inline void set_tile_radius (int value) { tile_radius = value; }
     inline void set_tile_diameter (int value) { tile_diameter = value; }
index dfa7453c5bc28f64c431af85638fdadcdfaa9963..dfb3711cd1e8ccef5bcb7a9314f2689da38d5e1b 100644 (file)
@@ -68,7 +68,7 @@ fgLoadFlight (istream &input)
                                // it would be better if FGFS just
                                // noticed the new lat/lon.
   if (retval) {
-    bool freeze;
+    bool freeze = globals->get_freeze();
     FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
     if ( !freeze ) 
       globals->set_freeze( true );
index 4b70193e1f354062aa1bb0f587928c349ab89e02..707d3801412cb0736d3b15fc55810319a545c4df 100644 (file)
@@ -34,7 +34,8 @@
 
 
 // Constructor
-FGViewer::FGViewer( void )
+FGViewer::FGViewer( void ):
+fov(55.0)
 {
 }
 
index 087b59c75dd23b5d528178b4e0aadba3b5cd2e5b..8475b24c37b6a17fbe9e3adf9a1932f4872d390d 100644 (file)
 #include <plib/sg.h>           // plib include
 
 
+#define FG_FOV_MIN 0.1
+#define FG_FOV_MAX 179.9
+
+
 // Define a structure containing view information
 class FGViewer {
 
@@ -55,6 +59,12 @@ protected:
 
     fgViewType _type;
 
+    // the field of view in the x (width) direction
+    double fov; 
+
+    // ratio of x and y fov's; fov(y) = fov(x) * win_ratio
+    double win_ratio;
+
     // the current view offset angle from forward (rotated about the
     // view_up vector)
     double view_offset;
@@ -115,6 +125,8 @@ public:
     //////////////////////////////////////////////////////////////////////
     // setter functions
     //////////////////////////////////////////////////////////////////////
+    inline void set_fov( double amount ) { fov = amount; }
+    inline void set_win_ratio( double r ) { win_ratio = r; }
     inline void set_view_offset( double a ) {
        set_dirty();
        view_offset = a;
@@ -150,6 +162,8 @@ public:
     inline int get_type() const { return _type ; }
     inline int is_a( int t ) const { return get_type() == t ; }
     inline bool is_dirty() const { return dirty; }
+    inline double get_fov() const { return fov; }
+    inline double get_win_ratio() const { return win_ratio; }
     inline double get_view_offset() const { return view_offset; }
     inline double get_goal_view_offset() const { return goal_view_offset; }
     inline double *get_geod_view_pos() { return geod_view_pos; }
index 74d5be64c98d875da73cae43f0f6d389764a017c..acbc0ed3f70388b93028a48a55347601890e3710 100644 (file)
@@ -102,8 +102,7 @@ static void print_sgMat4( sgMat4 &in) {
 // Update the view parameters
 void FGViewerLookAt::update() {
     Point3D tmp;
-    sgVec3 minus_z, forward;
-    sgMat4 VIEWo;
+    sgVec3 minus_z;
 
     // calculate the cartesion coords of the current lat/lon/0 elev
     Point3D p = Point3D( geod_view_pos[0],