[osg-users] OSG 3.4.0 osgViewerMFC can not display model

Glen A Johnson Jr. glenajohnsonjr at msn.com
Tue Jul 28 10:26:34 PDT 2015


I've run into the same issue in my applications. I believe the issue is from
a change in the osgViewer Library in GraphicsWindow32.cpp.

In GraphicsWindowWin32::init()

The following check has been added since the 3.2.1 version:

 

    int windowX = 0, windowY = 0, windowWidth = 0, windowHeight = 0;

    if (_traits.valid())

    {

        windowX = _traits->x;

        windowY = _traits->y;

        windowWidth = _traits->width;

        windowHeight = _traits->height;

    }

 

    if (areWindowDimensionsChanged(_hwnd, _screenOriginX, _screenOriginY,
windowX, windowY, windowWidth, windowHeight))

    {

        resized(windowX, windowY, windowWidth, windowHeight);

    }

In cases where the window has been created outside of osg and the window
handle is added to the graphics context as in the osgViewerMFC application,
the check in areWindowDimensionsChanged() will always be true since it is
assuming that the window passed in via _traits is in the overall screenspace
and not relative to the view. When resized() is called with the updated
window the graphics window is offset from the previously created window. I
believe if Rain moves his osgViewerMFC  application window to the upper left
corner of the screenspace he will see something like the view below where
the view is offset from the intended window. 



I implemented the following change which corrects the issue for my
applications as well as the osgViewerMFC in GraphicsWindow32.cpp.

 

       bool checkchange = false;

       int windowX = 0, windowY = 0, windowWidth = 0, windowHeight = 0;

 

       if (_traits.valid())

       {

 

              checkchange = (_traits->x != 0) || (_traits->y != 0);

              if (checkchange)

              {

                     windowX = _traits->x;

                     windowY = _traits->y;

                     windowWidth = _traits->width;

                     windowHeight = _traits->height;

              }

       }

       else

              checkchange = true;

 

       if (checkchange)

       {

              if (areWindowDimensionsChanged(_hwnd, _screenOriginX,
_screenOriginY, windowX, windowY, windowWidth, windowHeight))

              {

                     resized(windowX, windowY, windowWidth, windowHeight);

              }

       }

 

I believe this preserves the intent of the added check which works correctly
when the process uses GraphicsWindowWin32::createWindow() to create the
graphics window.

I have attached the modified GrahicsWindowWin32.cpp file for consideration. 

 

Glen Johnson

Phone: 321-696-3122

Email: glenajohnsonjr at msn.com

 

From: osg-users [mailto:osg-users-bounces at lists.openscenegraph.org] On
Behalf Of Rain
Sent: Tuesday, July 28, 2015 11:18 AM
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] OSG 3.4.0 osgViewerMFC can not display model

 

Hi,

  I compiled OSG 3.4.0 rc7 using VC2010 on WIN7, but osgViewerMFC can not
work like the old version, when I open a model, it can not display model, is
it a bug?





 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150728/d1e794a0/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 194704 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150728/d1e794a0/attachment-0004.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 66043 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150728/d1e794a0/attachment-0005.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 12121 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150728/d1e794a0/attachment-0002.png>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: GraphicsWindowWin32.cpp
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150728/d1e794a0/attachment-0001.asc>


More information about the osg-users mailing list