Hello,

I am  trying to find the right way to update my 2D camera after a window
resize. I check all the mailing list but I can't find the trick.
Maybe somebody can help.
I try the followings

1. Setting up the camera:
...
camera2d = new osg::Camera;
camera2d->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

osgViewer::Viewer::Windows windows;
viewerWindow->getWindows(windows);
if (windows.empty())
        return;
camera2d->setGraphicsContext(windows[0]);

camera2d->setProjectionMatrixAsOrtho2D(0, viewerWindow->width(), 0,
viewerWindow->height());
camera2d->setViewport(new
osg::Viewport(*(viewerWindow->getCamera()->getViewport())));
...

2. The resizeGL method from my Qt OSG adapter class

void QtOsgWidget::resizeGL(int width, int height)
{
        _gw->getEventQueue()->windowResize(0, 0, width, height);
        _gw->resized(0, 0, width, height);
// Seems not working
        _gw->resizedImplementation(0, 0, width, height);

// a "manual" update will work, but I think this
// is not the elegant way to do it

        osg::GraphicsContext::Cameras cameras = _gw->getCameras();
        osg::Camera * camera = cameras.back(); // My Ortho2D Camera

// This will work!
        camera->setProjectionMatrixAsOrtho2D(0, width, 0, height);
}

Many thanks for a tip.

Karl ...


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to