]> git.mxchange.org Git - flightgear.git/commitdiff
1. Tidies up h-FOV/v-FOV handling and makes window scale depend on
authorcurt <curt>
Tue, 5 Feb 2002 05:51:11 +0000 (05:51 +0000)
committercurt <curt>
Tue, 5 Feb 2002 05:51:11 +0000 (05:51 +0000)
max(width, height) by default (easily changeable) rather than just width.
(src/GUI/gui.cxx, src/Main/main.cxx, src/Main/viewer.cxx, src/Main/viewer.hxx)

src/GUI/gui.cxx
src/Main/main.cxx
src/Main/viewer.cxx
src/Main/viewer.hxx
src/Sound/soundmgr.cxx

index abae196636d066dce800bf097f85b24d63dc0575..850423e32b90f1de1869809f2d8c4b3ecf39283d 100644 (file)
@@ -525,8 +525,8 @@ void fgHiResDump()
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
-    float fov = globals->get_current_view()->get_fov();
-    ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
+    ssgSetFOV( globals->get_current_view()->get_h_fov(),
+              globals->get_current_view()->get_v_fov() );
     // ssgSetNearFar( 10.0f, 120000.0f );
     ssgSetNearFar( 0.5f, 1200000.0f );
 
index 75e9f05fb7b7e8b3902b139b0113785d4f0aed83..291fa049c772f9cf530e7d4c196386fda63e0aef 100644 (file)
@@ -668,8 +668,8 @@ void fgRenderFrame( void ) {
 
        // glMatrixMode( GL_PROJECTION );
        // glLoadIdentity();
-       float fov = globals->get_current_view()->get_fov();
-       ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
+       ssgSetFOV( globals->get_current_view()->get_h_fov(),
+                  globals->get_current_view()->get_v_fov() );
 
        double agl = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
            - scenery.get_cur_elev();
@@ -1309,8 +1309,8 @@ void fgReshape( int width, int height ) {
     fgSetInt("/sim/startup/xsize", width);
     fgSetInt("/sim/startup/ysize", height);
 
-    float fov = globals->get_current_view()->get_fov();
-    ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
+    ssgSetFOV( globals->get_current_view()->get_h_fov(),
+              globals->get_current_view()->get_v_fov() );
 
     fgHUDReshape();
 }
index aafa39b0ca9544e5a1e45caf08e1c97455d60034..cf1e9073f5a9ca99c77a587e5235ada2a0786940 100644 (file)
@@ -37,6 +37,7 @@
 // Constructor
 FGViewer::FGViewer( void ):
     fov(55.0),
+    scalingType(FG_SCALING_MAX),
     view_offset(0.0),
     goal_view_offset(0.0),
     view_tilt(0.0),
@@ -69,6 +70,47 @@ FGViewer::unbind ()
 {
 }
 
+double
+FGViewer::get_h_fov()
+{
+    switch (scalingType) {
+    case FG_SCALING_WIDTH:  // h_fov == fov
+       return fov;
+    case FG_SCALING_MAX:
+       if (aspect_ratio < 1.0) {
+           // h_fov == fov
+           return fov;
+       } else {
+           // v_fov == fov
+           return atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) / aspect_ratio) *
+               SG_RADIANS_TO_DEGREES * 2;
+       }
+    default:
+       assert(false);
+    }
+}
+
+double
+FGViewer::get_v_fov()
+{
+    switch (scalingType) {
+    case FG_SCALING_WIDTH:  // h_fov == fov
+       return atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) * aspect_ratio) *
+           SG_RADIANS_TO_DEGREES * 2;
+    case FG_SCALING_MAX:
+       if (aspect_ratio < 1.0) {
+           // h_fov == fov
+           return atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) * aspect_ratio) *
+               SG_RADIANS_TO_DEGREES * 2;
+       } else {
+           // v_fov == fov
+           return fov;
+       }
+    default:
+       assert(false);
+    }
+}
+
 void
 FGViewer::update (int dt)
 {
index 64cee08deb4360257461f66eee1b1958802055dd..62b2d6c4ebf9f3709253768ca9ffe86e3bced500 100644 (file)
@@ -52,6 +52,13 @@ public:
        FG_HPR = 2
     };
 
+    enum fgScalingType {  // nominal Field Of View actually applies to ...
+       FG_SCALING_WIDTH,       // window width
+       FG_SCALING_MAX,         // max(width, height)
+       // FG_SCALING_G_MEAN,      // geometric_mean(width, height)
+       // FG_SCALING_INDEPENDENT  // whole screen
+    };
+
 private:
 
     // flag forcing a recalc of derived view parameters
@@ -60,13 +67,11 @@ private:
 protected:
 
     fgViewType _type;
+    fgScalingType scalingType;
 
-    // the field of view in the x (width) direction
+    // the nominal field of view (angle, in degrees)
     double fov; 
 
-    // ratio of x and y fov's; fov(y) = fov(x) * fov_ratio
-    double fov_ratio;
-
     // ratio of window width and height; height = width * aspect_ratio
     double aspect_ratio;
 
@@ -143,13 +148,13 @@ public:
     //////////////////////////////////////////////////////////////////////
     // setter functions
     //////////////////////////////////////////////////////////////////////
-    inline void set_fov( double amount ) { fov = amount; }
-    // Don't provide set_fov_ratio explicitely. Use set_aspect_ratio
-    // instead.
+
+    inline void set_fov( double fov_deg ) {
+       fov = fov_deg;
+    }
+
     inline void set_aspect_ratio( double r ) {
        aspect_ratio = r;
-       fov_ratio = atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) * aspect_ratio) *
-           SG_RADIANS_TO_DEGREES / (fov/2);
     }
     inline void set_view_offset( double a ) {
        set_dirty();
@@ -215,7 +220,6 @@ public:
     inline bool is_dirty() const { return dirty; }
     inline double get_fov() const { return fov; }
     inline double get_aspect_ratio() const { return aspect_ratio; }
-    inline double get_fov_ratio() const { return fov_ratio; }
     inline double get_view_offset() const { return view_offset; }
     inline bool get_reverse_view_offset() const { return reverse_view_offset; }
     inline double get_goal_view_offset() const { return goal_view_offset; }
@@ -224,6 +228,10 @@ public:
     inline double *get_geod_view_pos() { return geod_view_pos; }
     inline float *get_pilot_offset() { return pilot_offset; }
     inline double get_sea_level_radius() const { return sea_level_radius; }
+    // Get horizontal field of view angle, in degrees.
+    double get_h_fov();
+    // Get vertical field of view angle, in degrees.
+    double get_v_fov();
 
     //////////////////////////////////////////////////////////////////////
     // derived values accessor functions
index 3bf3ea0e84aa8774210b15de55ffa9b3bcac7f86..834632fbac75c3dd628929d2fe4eeb7941e28b4a 100644 (file)
@@ -64,14 +64,18 @@ FGSimpleSound::~FGSimpleSound() {
 // constructor
 FGSoundMgr::FGSoundMgr() {
     audio_sched = new slScheduler( 8000 );
-    audio_sched -> setMaxConcurrent ( 6 ); 
+    if ( audio_sched->notWorking() ) {
+       SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
+    } else {
+       audio_sched -> setMaxConcurrent ( 6 ); 
 
-    audio_mixer = new smMixer;
+       audio_mixer = new smMixer;
 
-    SG_LOG( SG_GENERAL, SG_INFO,
-           "Rate = " << audio_sched->getRate()
-           << "  Bps = " << audio_sched->getBps()
-           << "  Stereo = " << audio_sched->getStereo() );
+       SG_LOG( SG_GENERAL, SG_INFO,
+               "Rate = " << audio_sched->getRate()
+               << "  Bps = " << audio_sched->getBps()
+               << "  Stereo = " << audio_sched->getStereo() );
+    }
 }
 
 // destructor