1. Tidies up h-FOV/v-FOV handling and makes window scale depend on
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)
This commit is contained in:
parent
e12f6757d5
commit
f149bcba97
5 changed files with 76 additions and 22 deletions
|
@ -525,8 +525,8 @@ void fgHiResDump()
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
|
ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
|
||||||
float fov = globals->get_current_view()->get_fov();
|
ssgSetFOV( globals->get_current_view()->get_h_fov(),
|
||||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
globals->get_current_view()->get_v_fov() );
|
||||||
// ssgSetNearFar( 10.0f, 120000.0f );
|
// ssgSetNearFar( 10.0f, 120000.0f );
|
||||||
ssgSetNearFar( 0.5f, 1200000.0f );
|
ssgSetNearFar( 0.5f, 1200000.0f );
|
||||||
|
|
||||||
|
|
|
@ -668,8 +668,8 @@ void fgRenderFrame( void ) {
|
||||||
|
|
||||||
// glMatrixMode( GL_PROJECTION );
|
// glMatrixMode( GL_PROJECTION );
|
||||||
// glLoadIdentity();
|
// glLoadIdentity();
|
||||||
float fov = globals->get_current_view()->get_fov();
|
ssgSetFOV( globals->get_current_view()->get_h_fov(),
|
||||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
globals->get_current_view()->get_v_fov() );
|
||||||
|
|
||||||
double agl = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
|
double agl = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
|
||||||
- scenery.get_cur_elev();
|
- scenery.get_cur_elev();
|
||||||
|
@ -1309,8 +1309,8 @@ void fgReshape( int width, int height ) {
|
||||||
fgSetInt("/sim/startup/xsize", width);
|
fgSetInt("/sim/startup/xsize", width);
|
||||||
fgSetInt("/sim/startup/ysize", height);
|
fgSetInt("/sim/startup/ysize", height);
|
||||||
|
|
||||||
float fov = globals->get_current_view()->get_fov();
|
ssgSetFOV( globals->get_current_view()->get_h_fov(),
|
||||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
globals->get_current_view()->get_v_fov() );
|
||||||
|
|
||||||
fgHUDReshape();
|
fgHUDReshape();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
// Constructor
|
// Constructor
|
||||||
FGViewer::FGViewer( void ):
|
FGViewer::FGViewer( void ):
|
||||||
fov(55.0),
|
fov(55.0),
|
||||||
|
scalingType(FG_SCALING_MAX),
|
||||||
view_offset(0.0),
|
view_offset(0.0),
|
||||||
goal_view_offset(0.0),
|
goal_view_offset(0.0),
|
||||||
view_tilt(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
|
void
|
||||||
FGViewer::update (int dt)
|
FGViewer::update (int dt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,13 @@ public:
|
||||||
FG_HPR = 2
|
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:
|
private:
|
||||||
|
|
||||||
// flag forcing a recalc of derived view parameters
|
// flag forcing a recalc of derived view parameters
|
||||||
|
@ -60,13 +67,11 @@ private:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
fgViewType _type;
|
fgViewType _type;
|
||||||
|
fgScalingType scalingType;
|
||||||
|
|
||||||
// the field of view in the x (width) direction
|
// the nominal field of view (angle, in degrees)
|
||||||
double fov;
|
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
|
// ratio of window width and height; height = width * aspect_ratio
|
||||||
double aspect_ratio;
|
double aspect_ratio;
|
||||||
|
|
||||||
|
@ -143,13 +148,13 @@ public:
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// setter functions
|
// setter functions
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
inline void set_fov( double amount ) { fov = amount; }
|
|
||||||
// Don't provide set_fov_ratio explicitely. Use set_aspect_ratio
|
inline void set_fov( double fov_deg ) {
|
||||||
// instead.
|
fov = fov_deg;
|
||||||
|
}
|
||||||
|
|
||||||
inline void set_aspect_ratio( double r ) {
|
inline void set_aspect_ratio( double r ) {
|
||||||
aspect_ratio = 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 ) {
|
inline void set_view_offset( double a ) {
|
||||||
set_dirty();
|
set_dirty();
|
||||||
|
@ -215,7 +220,6 @@ public:
|
||||||
inline bool is_dirty() const { return dirty; }
|
inline bool is_dirty() const { return dirty; }
|
||||||
inline double get_fov() const { return fov; }
|
inline double get_fov() const { return fov; }
|
||||||
inline double get_aspect_ratio() const { return aspect_ratio; }
|
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 double get_view_offset() const { return view_offset; }
|
||||||
inline bool get_reverse_view_offset() const { return reverse_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_goal_view_offset() const { return goal_view_offset; }
|
||||||
|
@ -224,6 +228,10 @@ public:
|
||||||
inline double *get_geod_view_pos() { return geod_view_pos; }
|
inline double *get_geod_view_pos() { return geod_view_pos; }
|
||||||
inline float *get_pilot_offset() { return pilot_offset; }
|
inline float *get_pilot_offset() { return pilot_offset; }
|
||||||
inline double get_sea_level_radius() const { return sea_level_radius; }
|
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
|
// derived values accessor functions
|
||||||
|
|
|
@ -64,14 +64,18 @@ FGSimpleSound::~FGSimpleSound() {
|
||||||
// constructor
|
// constructor
|
||||||
FGSoundMgr::FGSoundMgr() {
|
FGSoundMgr::FGSoundMgr() {
|
||||||
audio_sched = new slScheduler( 8000 );
|
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,
|
SG_LOG( SG_GENERAL, SG_INFO,
|
||||||
"Rate = " << audio_sched->getRate()
|
"Rate = " << audio_sched->getRate()
|
||||||
<< " Bps = " << audio_sched->getBps()
|
<< " Bps = " << audio_sched->getBps()
|
||||||
<< " Stereo = " << audio_sched->getStereo() );
|
<< " Stereo = " << audio_sched->getStereo() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
|
|
Loading…
Add table
Reference in a new issue