Could you provide a screenshot illustrating the distortion?

W.r.t othographic projection, see include/osg/Camera header for its
setProjectionMatrxiAsOrtho2D.  Also see the example osghud.

Robert.

On 5/31/07, Johannes Brunen <[EMAIL PROTECTED]> wrote:
Hi,

I'm in the process of integrating OSG into a gui toolkit. I'm using a
composite viewer and
can see my sample geometry on the window canvas. Howerver, the rendered
geometry is
distorted in the y direction of the window. Can anyone tell me what I
have missed in my
toolkit integration. The following is a sketch of what I have done:

Inside the create function of my toolkit window:
    PIXELFORMATDESCRIPTOR pixelFormat = { ... };
    HDC hdc = ::GetDC(_hWnd);
    int pixelFormatIndex = ::ChoosePixelFormat(hdc, &pixelFormat);
    ::SetPixelFormat(hdc, pixelFormatIndex, &pixelFormat)

    RECT rect;
    ::GetClientRect(_hWnd, &rect);
    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits;
    traits->inheritedWindowData = new
osgViewer::GraphicsWindowWin32::WindowData(_hWnd);
    traits->x = rect.left;
    traits->y = rect.top;
    traits->width = rect.right - rect.left;
    traits->height = rect.bottom - rect.top;
    traits->windowDecoration = false;
    traits->doubleBuffer = true;
    traits->sharedContext = 0;
    traits->supportsResize = true;
    traits->depth = 32;

    osg::ref_ptr<osg::GraphicsContext> gc =
osg::GraphicsContext::createGraphicsContext(traits.get());

    osg::ref_ptr<osg::Group> root = new osg::Group;
    root->addChild(createScene());

    osgUtil::Optimizer optimizer;
    optimizer.optimize(root.get());
    optimizer.reset();

    osg::ref_ptr<osgViewer::CompositeViewer> viewer = new
osgViewer::CompositeViewer;

    osgViewer::View* view = new osgViewer::View;

    view->setSceneData(root.get());
    view->getCamera()->setGraphicsContext(gc.get());
    view->getCamera()->setViewport(new osg::Viewport(0,0, traits->width,
traits->height));
    view->setCameraManipulator(new osgGA::TrackballManipulator);

    viewer->addView(view);

    osgDB::writeNodeFile(*(root.get()), "Simple.osg" );

    StartRenderLoop();

On loading the written 'Simple.osg' file with the osgViewer.exe demo
application everything looks pretty fine.
But in my render window the geometry is distorted in one direction.
Additionally, I would like to use an orthographic projection camera. Is
there any convenience functionallity for
setting up the camera for this.

Johannes

_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to