Fixes for win_ratio/aspect_ratio confusion. It was due to confusion in the
meaning of "win_ratio". I've removed win_ratio and added fov_ratio and aspect_ratio, as it seems both are needed. n.b. The multi-line changes in fgReshape comprise: extracting common code, removing an apparently arbitrary "+1" on the view height, changing "set_win_ratio" to "set_aspect_ratio".
This commit is contained in:
parent
fe8c751f1b
commit
b6a259dc90
7 changed files with 39 additions and 33 deletions
|
@ -1033,8 +1033,8 @@ static void set_hud_color(float r, float g, float b) {
|
||||||
void fgUpdateHUD( void ) {
|
void fgUpdateHUD( void ) {
|
||||||
|
|
||||||
static const float normal_aspect = float(640) / float(480);
|
static const float normal_aspect = float(640) / float(480);
|
||||||
// note: win_ratio is Y/X
|
// note: aspect_ratio is Y/X
|
||||||
float current_aspect = 1.0f/globals->get_current_view()->get_win_ratio();
|
float current_aspect = 1.0f/globals->get_current_view()->get_aspect_ratio();
|
||||||
if( current_aspect > normal_aspect ) {
|
if( current_aspect > normal_aspect ) {
|
||||||
float aspect_adjust = current_aspect / normal_aspect;
|
float aspect_adjust = current_aspect / normal_aspect;
|
||||||
float adjust = 320.0f*aspect_adjust - 320.0f;
|
float adjust = 320.0f*aspect_adjust - 320.0f;
|
||||||
|
|
|
@ -251,12 +251,12 @@ void HudLadder :: draw( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
xvvr = (((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi)*
|
xvvr = (((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi)*
|
||||||
(factor/globals->get_current_view()->get_win_ratio()));
|
(factor/globals->get_current_view()->get_aspect_ratio()));
|
||||||
drift = ((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi);
|
drift = ((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi);
|
||||||
yvvr = ((actslope - pitch_value)*factor);
|
yvvr = ((actslope - pitch_value)*factor);
|
||||||
vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor;
|
vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor;
|
||||||
vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))*
|
vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))*
|
||||||
(factor/globals->get_current_view()->get_win_ratio());
|
(factor/globals->get_current_view()->get_aspect_ratio());
|
||||||
// printf("%f %f %f %f\n",vel_x,vel_y,drift,psi);
|
// printf("%f %f %f %f\n",vel_x,vel_y,drift,psi);
|
||||||
//****************************************************************
|
//****************************************************************
|
||||||
// OBJECT MOVING RETICLE
|
// OBJECT MOVING RETICLE
|
||||||
|
|
|
@ -520,7 +520,7 @@ void fgHiResDump()
|
||||||
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();
|
float fov = globals->get_current_view()->get_fov();
|
||||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
|
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
||||||
// ssgSetNearFar( 10.0f, 120000.0f );
|
// ssgSetNearFar( 10.0f, 120000.0f );
|
||||||
ssgSetNearFar( 0.5f, 1200000.0f );
|
ssgSetNearFar( 0.5f, 1200000.0f );
|
||||||
|
|
||||||
|
|
|
@ -587,12 +587,14 @@ bool fgInitSubsystems( void ) {
|
||||||
// Initialize the view manager subsystem.
|
// Initialize the view manager subsystem.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if 0 /* As this wrongly does an integer division and gets x and y the wrong way around, I guess it's not needed. JAF */
|
||||||
// Initialize win_ratio parameters
|
// Initialize win_ratio parameters
|
||||||
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
|
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
|
||||||
globals->get_viewmgr()->get_view(i)->
|
globals->get_viewmgr()->get_view(i)->
|
||||||
set_win_ratio( fgGetInt("/sim/startup/xsize") /
|
set_win_ratio( fgGetInt("/sim/startup/xsize") /
|
||||||
fgGetInt("/sim/startup/ysize") );
|
fgGetInt("/sim/startup/ysize") );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialize pilot view
|
// Initialize pilot view
|
||||||
FGViewerRPH *pilot_view =
|
FGViewerRPH *pilot_view =
|
||||||
|
|
|
@ -952,7 +952,9 @@ getFOV ()
|
||||||
static void
|
static void
|
||||||
setFOV (double fov)
|
setFOV (double fov)
|
||||||
{
|
{
|
||||||
globals->get_current_view()->set_fov( fov );
|
if ( fov < 180 ) {
|
||||||
|
globals->get_current_view()->set_fov( fov );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static long
|
static long
|
||||||
|
|
|
@ -684,7 +684,7 @@ void fgRenderFrame( void ) {
|
||||||
// glMatrixMode( GL_PROJECTION );
|
// glMatrixMode( GL_PROJECTION );
|
||||||
// glLoadIdentity();
|
// glLoadIdentity();
|
||||||
float fov = globals->get_current_view()->get_fov();
|
float fov = globals->get_current_view()->get_fov();
|
||||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
|
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
||||||
|
|
||||||
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.cur_elev;
|
- scenery.cur_elev;
|
||||||
|
@ -1391,36 +1391,28 @@ static void fgIdleFunction ( void ) {
|
||||||
// options.cxx needs to see this for toggle_panel()
|
// options.cxx needs to see this for toggle_panel()
|
||||||
// Handle new window size or exposure
|
// Handle new window size or exposure
|
||||||
void fgReshape( int width, int height ) {
|
void fgReshape( int width, int height ) {
|
||||||
// for all views
|
int view_h;
|
||||||
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
|
|
||||||
if ( ! fgPanelVisible() || idle_state != 1000 ) {
|
if ( fgPanelVisible() && idle_state == 1000 ) {
|
||||||
globals->get_viewmgr()->get_view(i)->
|
view_h = (int)(height * (current_panel->getViewHeight() -
|
||||||
set_win_ratio( (float)height / (float)width );
|
current_panel->getYOffset()) / 768.0);
|
||||||
} else {
|
} else {
|
||||||
int view_h =
|
view_h = height;
|
||||||
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 ) {
|
// for all views
|
||||||
glViewport(0, 0 , (GLint)(width), (GLint)(height) );
|
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
|
||||||
} else {
|
globals->get_viewmgr()->get_view(i)->
|
||||||
int view_h =
|
set_aspect_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) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glViewport( 0, (GLint)(height - view_h), (GLint)(width), (GLint)(view_h) );
|
||||||
|
|
||||||
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();
|
float fov = globals->get_current_view()->get_fov();
|
||||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
|
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
||||||
|
|
||||||
fgHUDReshape();
|
fgHUDReshape();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,11 @@ protected:
|
||||||
// the field of view in the x (width) direction
|
// the field of view in the x (width) direction
|
||||||
double fov;
|
double fov;
|
||||||
|
|
||||||
// ratio of x and y fov's; fov(y) = fov(x) * win_ratio
|
// ratio of x and y fov's; fov(y) = fov(x) * fov_ratio
|
||||||
double win_ratio;
|
double fov_ratio;
|
||||||
|
|
||||||
|
// ratio of window width and height; height = width * aspect_ratio
|
||||||
|
double aspect_ratio;
|
||||||
|
|
||||||
// the current view offset angle from forward (rotated about the
|
// the current view offset angle from forward (rotated about the
|
||||||
// view_up vector)
|
// view_up vector)
|
||||||
|
@ -130,7 +133,13 @@ public:
|
||||||
// setter functions
|
// setter functions
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
inline void set_fov( double amount ) { fov = amount; }
|
inline void set_fov( double amount ) { fov = amount; }
|
||||||
inline void set_win_ratio( double r ) { win_ratio = r; }
|
// Don't provide set_fov_ratio explicitely. Use set_aspect_ratio
|
||||||
|
// instead.
|
||||||
|
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 ) {
|
inline void set_view_offset( double a ) {
|
||||||
set_dirty();
|
set_dirty();
|
||||||
view_offset = a;
|
view_offset = a;
|
||||||
|
@ -176,7 +185,8 @@ public:
|
||||||
inline int is_a( int t ) const { return get_type() == t ; }
|
inline int is_a( int t ) const { return get_type() == t ; }
|
||||||
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_win_ratio() const { return win_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; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue