Tim Moore wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> dave perry wrote:
> | Patch adds a member function to FGRenderer class that returns the
> | current aspect ratio.  Uses this in place of 4.0/3.0 in setFOV and
> | setNearFar.
> |
> | The diff follows:
> |
> This seems a little confusing / confused. In setFOV, why would you ignore the 
> w argument?
> Now, I happen to know that /sim/startup/xsize is set to the value of w 
> somewhere in
> one of the callers, but this is not clear at all. Can we untangle this a bit?
>   
In setFOV, you can use w/h for the aspect ratio.  But in setNearFar just 
below this, w and h are not defined in that context, so you need to get 
the real current aspect ratio from some where.  I noticed that 
/sim/startup/xsize and /sim/startup/ysize we being updated as I changed 
the window, so it seemed most clear to define a getAspectRatio() member 
function in this class that was available to both setFOV and 
setNearFar.  This is certainly more correct than assuming an aspect 
ratio of 4.0/3.0 in both calls.
> Thanks for the bug fix all the same. I think we've blown off this problem 
> because it
> was unclear how to deal with multiple cameras (monitors / graphics cards), 
> but now we're
> only coding to the osgViewer interface, so it will be easier to arrive at a 
> coherent
> solution.
>   
It is interesting that with this patch, the osg branch behavior still 
depends on the fgfs configure switches.  There are still 3 cases:

case 1:  Don't enable either SDL or osgviewer (in this case, you are 
using either glut or freeglut). 

    This case seems to work just like the plib branch.  The initial view
    has the right aspect ratio as well as resized windows no matter what
    the initial --geometry= is.  Also, all the keyboard events are
    translated correctly.

case 2:  --enable-sdl is added to the ./configure command line.

    In this case the initial window has the correct aspect ratio as well
    as resized windows no matter what the initial --geometry= is.  But
    many keyboard event only work the first time.  I have tried to trace
    this bug down to no avail.

case 3:  --enable-osgviewer in place of --enable-sdl.

    In this case the initial window has the correct aspect ratio no
    matter what the initial --geometry= is.  But you need to adjust the
    window once to get the mouse events in the right coordinates. 
    Before this adjustment, the hot spots are vertically off.  Also, if
    you adjust the window width or height so as to have a different
    aspect ratio, the view will be distorted.

I believe we need to commit this patch so that those with non 4:3 
monitors can continue to develop aircraft and other models for the osg 
branch.  They can use either case 1 or case 3 to configure an osg branch 
fgfs compile and at least the first window will not be distorted.  I am 
continuing to use case 1.
> Tim
>
> | ? renderer.diff
> | Index: renderer.cxx
> | ===================================================================
> | RCS file: /var/cvs/FlightGear-0.9/source/src/Main/renderer.cxx,v
> | retrieving revision 1.100
> | diff -p -u -r1.100 renderer.cxx
> | --- renderer.cxx    6 Jan 2008 23:03:20 -0000    1.100
> | +++ renderer.cxx    16 Jan 2008 22:41:59 -0000
> | @@ -864,6 +864,11 @@ static float fov_height = 42.0;
> |  static float fov_near = 1.0;
> |  static float fov_far = 1000.0;
> |
> | +float FGRenderer::getAspectRatio() {
> | +    float xsize = fgGetInt("/sim/startup/xsize");
> | +    float ysize = fgGetInt("/sim/startup/ysize");
> | +    return xsize/ysize;
> | +}
> |
> |  /** FlightGear code should use this routine to set the FOV rather than
> |   *  calling the ssg routine directly
> | @@ -872,7 +877,7 @@ void FGRenderer::setFOV( float w, float
> |      fov_width = w;
> |      fov_height = h;
> |      osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
> | -    viewer->getCamera()->setProjectionMatrixAsPerspective(fov_height,
> | 4.0/3.0,
> | +    viewer->getCamera()->setProjectionMatrixAsPerspective(fov_height,
> | FGRenderer::getAspectRatio(),
> |                                                            fov_near,
> | fov_far);
> |  }
> |
> | @@ -886,7 +891,7 @@ n = 0.1;
> |      fov_near = n;
> |      fov_far = f;
> |      osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
> | -    viewer->getCamera()->setProjectionMatrixAsPerspective(fov_height,
> | 4.0/3.0,
> | +    viewer->getCamera()->setProjectionMatrixAsPerspective(fov_height,
> | FGRenderer::getAspectRatio(),
> |                                                            fov_near,
> | fov_far);
> |  }
> |
> | Index: renderer.hxx
> | ===================================================================
> | RCS file: /var/cvs/FlightGear-0.9/source/src/Main/renderer.hxx,v
> | retrieving revision 1.17
> | diff -p -u -r1.17 renderer.hxx
> | --- renderer.hxx    21 Nov 2007 20:51:50 -0000    1.17
> | +++ renderer.hxx    16 Jan 2008 22:41:59 -0000
> | @@ -32,6 +32,8 @@ public:
> |      void splashinit();
> |      void init();
> |
> | +    static float getAspectRatio();
> | +
> |      static void resize(int width, int height );
> |
> |      // calling update( refresh_camera_settings = false ) will not
> |
> | -------------------------------------------------------------------------
> | This SF.net email is sponsored by: Microsoft
> | Defy all challenges. Microsoft(R) Visual Studio 2008.
> | http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> | _______________________________________________
> | Flightgear-devel mailing list
> | Flightgear-devel@lists.sourceforge.net
> | https://lists.sourceforge.net/lists/listinfo/flightgear-devel
> |
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
>
> iD8DBQFHkfVteDhWHdXrDRURAuz6AJ9pU8rKI5Ww6/D+PYlLxEgOdJ997QCg1GKl
> dmuKp9gtD9vs5EY/zgIoMKY=
> =RgZN
> -----END PGP SIGNATURE-----
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Flightgear-devel mailing list
> Flightgear-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/flightgear-devel
>
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to