Hi Robert, thank you very much for your answer. It led me to implement at rather hacky (in my mind at least solution).
Instead of : double r = (double)m_OSGView.aspect_ratio*t; I now use: double r = (double)m_OSGView.aspect_ratio*(double)m_OSGView.aspect_ratio*t / mOSG->getOriginalAspect(); //where mOSG->getOriginalAspect() is the aspect ratio from the creation time of the graphicscontext. This gives me exactly the same view as in my 2.6.1 version when resizing the window, even though it feels very hacky. Thank you very much for your help. Jesper D. Thomsen AnyBody Technology A/S -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Robert Osfield Sent: 2. december 2010 14:40 To: OpenSceneGraph Users Subject: Re: [osg-users] Window content stretching when resized after updating from 2.6.1 to 2.8.3 Hi Jasper, There is chance that the issue comes from a fix to a bug rather than introduction of a bug, with your original code working around the bug. Removing the workaround could well just fix things. The reason why I suggest that is that I recall merging fixes to the way the projection matrices are updated, I don't recall the dates though, but I'm sure it's since 2.6.x. Try just removing your code that attempts to update the projection matrix when you the window is resized. Robert. On Thu, Dec 2, 2010 at 12:46 PM, Jesper D. Thomsen <[email protected]> wrote: > Hi all, I had hoped I would figure this out myself, but no luck so far. > > > > I just upgraded my OSG usage from 2.6.1 to 2.8.3, and without changing > anything about how my windows are set up, I'm now getting a behavior > where the viewed contents of a window stays the same when the window > is rescaled, whereas in 2.6.1 I would have a constant pixel-size for > the contents of the window when resized. Please see the attached > images if I'm not making myself clear enough (please note that the > HUD-text is supposed to be stretched to the window size in both versions). > > > > I'm using a release OSG 2.8.3, compiled on Visual Studio 2005 sp1, on > Vista > 64 (Nvidia Quadro graphics card). > > > > The camera and graphics context are created like this (done once): > > > > RECT rect; > > mViewer = new osgViewer::Viewer(); > > mViewer->setThreadingModel(osgViewer::Viewer::SingleThreaded); > > ::GetWindowRect(m_hWnd, &rect); > > osg::ref_ptr<osg::GraphicsContext::Traits> traits = new > osg::GraphicsContext::Traits; > > osg::ref_ptr<osg::Referenced> windata = new > osgViewer::GraphicsWindowWin32::WindowData(m_hWnd); > > traits->x = 0; > > traits->y = 0; > > traits->width = rect.right - rect.left; > > traits->height = rect.bottom - rect.top; > > traits->windowDecoration = false; > > traits->doubleBuffer = true; > > traits->sharedContext = 0; > > traits->setInheritedWindowPixelFormat = true; > > traits->supportsResize = true; > > traits->inheritedWindowData = windata; > > m_gc = osg::GraphicsContext::createGraphicsContext(traits.get()); > > camera = mViewer->getCamera(); > > camera->setGraphicsContext(m_gc.get()); > > camera->setViewport(new osg::Viewport(traits->x, traits->y, > camera->traits->width, > traits->height)); > > mViewer->addSlave(camera.get()); > > > > And for each frame I'm drawing I'm setting the camera like this: > > > > mOSG->getViewer()->getCamera()->getGraphicsContext()->resized(x, y, w, > mOSG->h); > > mOSG->getViewer()->getCamera()->setViewport(x,y,w,h); > > double n = (double)m_OSGView.near_dist; > > double f = (double)(m_OSGView.far_dist + > m_OSGView.eye_dist_add_ortho); > > double t = (double)(m_OSGView.focal_height/2.0f); > > double r = (double)m_OSGView.aspect_ratio*t; > > mOSG->getViewer()->getCamera()->setProjectionMatrixAsOrtho(-r,r,-t,t,n > mOSG->,f*50); > > > > > The eyepoint is set via setViewMatrix elsewhere. > > > > This worked just fine in OSG 2.6.1, but the behavior has changed in > 2.8.3, and I know that's it's probably something I'm either doing > wrong or forgetting to do, but I would like to keep the pixel-aspect > the same when resize the view, and any help/hints would be most > welcome. I'm just about to create a new graphicscontext with new > traits for each window resize, but I just know that that can't be the proper > way to solve this. > > > > Regards, and thanks in advance. > > > > > > Jesper D. Thomsen > > AnyBody Technology A/S > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph. > org > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

