Anti-aliasing issues

classic Classic list List threaded Threaded
3 messages Options
Daven Hem Daven Hem
Reply | Threaded
Open this post in threaded view
|

Anti-aliasing issues

Hello, everyone!
I have some anti-aliasing issues during test my osgEarth viewer in VB.NET form.
I put a picture box on VB.NET form and link osgEarth viewer to VB.NET form by using window handle.
I want to add anti-aliasing effect into my viewer but osgEarth viewer was divorced from VB.NET form and appeared as full-screen. Also anti-aliasing effect was not appeared. I attached VB.NET screenshots.
Please check my code and screenshots and teach me.
Thanks for your time.
Daven.


/************* My code snippet *************/

/** default constructor */
MyViewer::MyViewer(int handle, MyViewerSetting* setting) : Viewer(), _setting(setting)
{
        RECT rect;
        HWND hHwnd = (HWND)handle;
        GetWindowRect(hHwnd, &rect);

        osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(hHwnd);
        osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;

        traits->x = 0;
        traits->y = 0;
        traits->width = rect.right - rect.left;
        traits->height = rect.bottom - rect.top + 200;
        traits->windowDecoration = false;
        traits->doubleBuffer = true;
        traits->sharedContext = 0;
        traits->inheritedWindowData = windata;
        traits->samples = 8;

        // We must set the pixelformat before we can create the OSG Rendering Surface
        PIXELFORMATDESCRIPTOR pixelFormat =
        {
                sizeof(PIXELFORMATDESCRIPTOR),
                1,
                PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
                PFD_TYPE_RGBA,
                24,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0,
                24,
                0,
                0,
                PFD_MAIN_PLANE,
                0,
                0, 0, 0
        };

        HDC hdc = ::GetDC(hHwnd);
        if (hdc == 0)
        {
                return;
        }

        int pixelFormatIndex = ::ChoosePixelFormat(hdc, &pixelFormat);
        if (pixelFormatIndex == 0)
        {
                ::ReleaseDC(hHwnd, hdc);
                return;
        }

        if (!::SetPixelFormat(hdc, pixelFormatIndex, &pixelFormat))
        {
                ::ReleaseDC(hHwnd, hdc);
                return;
        }

        osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
        camera->setGraphicsContext(gc.get());
        camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
        camera->setDrawBuffer(GL_BACK);
        camera->setReadBuffer(GL_BACK);

        setCameraManipulator(new osgGA::TrackballManipulator);
        getCamera()->setClearColor(osg::Vec4(0.8, 0.8, 0.8, 1));
        addSlave(camera.get());

        _viewerBase = this;

        _mapManager = new MyMapManager(this);
        _cableSolution = new CableSolution(this);
        _shipManager = new ShipManager(this);
        _buildComplet = false;
        constructorInit();
}





Daven Hem Daven Hem
Reply | Threaded
Open this post in threaded view
|

Re: Anti-aliasing issues

Thanks. Glenn.
Any idea about this issue?
Daven Hem Daven Hem
Reply | Threaded
Open this post in threaded view
|

Re: Anti-aliasing issues

Any idea?