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)
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 );
// 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();
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();
}
// Constructor
FGViewer::FGViewer( void ):
fov(55.0),
+ scalingType(FG_SCALING_MAX),
view_offset(0.0),
goal_view_offset(0.0),
view_tilt(0.0),
{
}
+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)
{
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
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;
//////////////////////////////////////////////////////////////////////
// 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();
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; }
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
// 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