osgEarth3.0 can't show feature line in MFC frame

classic Classic list List threaded Threaded
3 messages Options
Bin.L Bin.L
Reply | Threaded
Open this post in threaded view
|

osgEarth3.0 can't show feature line in MFC frame

when I load annotation.earth in MFC frame, the feature line can't show normal.

but it show normal in osgearth_viewer


here are my dome code

void COSGObject::InitOSG()
{
    InitSceneGraph();
    InitCameraConfig();
    InitOsgEarth();

}

void COSGObject::InitSceneGraph()
{
    mRoot = new osg::Group;
    osg::ref_ptr<osg::Node> mp = osgDB::readNodeFile("C:\\OSG\\data\\annotation.earth");
    mRoot->addChild(mp);
    mapNode = dynamic_cast<osgEarth::MapNode*>(mp.get());
}

void COSGObject::InitCameraConfig()
{
    RECT rect;
    mViewer = new osgViewer::Viewer;
    ::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->inheritedWindowData = windata;
    osg::GraphicsContext * gc = osg::GraphicsContext::createGraphicsContext(traits);

    osg::ref_ptr<osg::Camera> camera = new osg::Camera;
    camera->setGraphicsContext(gc);
    camera->setViewport(new osg::Viewport(traits->x, traits->y, traits->width, traits->height));
    camera->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0, 1000.0);

    mViewer->setCamera(camera);
    mViewer->setSceneData(mRoot);
    mViewer->realize();
        mViewer->getCamera()->setSmallFeatureCullingPixelSize(-1.0f);
}

void COSGObject::InitOsgEarth()
{
        em = new osgEarth::Util::EarthManipulator;
        if (mapNode.valid())
        {
                em->setNode(mapNode);
        }
        em->getSettings()->setArcViewpointTransitions(true);
        mViewer->setCameraManipulator(em);
}

it works well in osgearth2.8

osgearth for aircraft display
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth3.0 can't show feature line in MFC frame

You probably need to add this (to one of your top level statesets, like on the camera).

#include <osgEarth/GLUtils>
...
GLUtils::setGlobalDefaults(group->getOrCreateStateSet());
Glenn Waldron / Pelican Mapping
Bin.L Bin.L
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth3.0 can't show feature line in MFC frame

Yes, It works!,just set mapnode
osgEarth::GLUtils::setGlobalDefaults(mapNode->getOrCreateStateSet());
then the feature line show normal.
Thanks a lot!
osgearth for aircraft display