osgEarth 2.1.1
Public Member Functions | Private Attributes

MyGraphicsContext Struct Reference

List of all members.

Public Member Functions

 MyGraphicsContext ()
bool valid () const
 MyGraphicsContext ()
bool valid () const

Private Attributes

osg::ref_ptr
< osg::GraphicsContext > 
_gc

Detailed Description

Definition at line 31 of file osgearth_ocean.cpp.


Constructor & Destructor Documentation

MyGraphicsContext::MyGraphicsContext ( ) [inline]

Definition at line 33 of file osgearth_ocean.cpp.

        {
            osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
            traits->x = 0;
            traits->y = 0;
            traits->width = 1;
            traits->height = 1;
            traits->windowDecoration = false;
            traits->doubleBuffer = false;
            traits->sharedContext = 0;
            traits->pbuffer = true;

            _gc = osg::GraphicsContext::createGraphicsContext(traits.get());

            if (!_gc)
            {
                traits->pbuffer = false;
                _gc = osg::GraphicsContext::createGraphicsContext(traits.get());
            }

            if (_gc.valid()) 
            {
                _gc->realize();
                _gc->makeCurrent();
            }
        }
MyGraphicsContext::MyGraphicsContext ( ) [inline]

Definition at line 38 of file Capabilities.cpp.

    {
        osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
        traits->x = 0;
        traits->y = 0;
        traits->width = 1;
        traits->height = 1;
        traits->windowDecoration = false;
        traits->doubleBuffer = false;
        traits->sharedContext = 0;
        traits->pbuffer = false;

        // Intel graphics adapters dont' support pbuffers, and some of their drivers crash when
        // you try to create them. So by default we will only use the unmapped/pbuffer method
        // upon special request.
        if ( getenv( "OSGEARTH_USE_PBUFFER_TEST" ) )
        {
            traits->pbuffer = true;
            OE_INFO << LC << "Activating pbuffer test for graphics capabilities" << std::endl;
            _gc = osg::GraphicsContext::createGraphicsContext(traits.get());
            if ( !_gc.valid() )
                OE_WARN << LC << "Failed to create pbuffer" << std::endl;
        }

        if (!_gc.valid())
        {
            // fall back on a mapped window
            traits->pbuffer = false;
            _gc = osg::GraphicsContext::createGraphicsContext(traits.get());
        }

        if (_gc.valid()) 
        {
            _gc->realize();
            _gc->makeCurrent();

            if ( traits->pbuffer == false )
            {
                OE_DEBUG << LC << "Realized graphics window for OpenGL operations." << std::endl;
            }
            else
            {
                OE_DEBUG << LC << "Realized pbuffer for OpenGL operations." << std::endl;
            }
        }
        else
        {
            OE_WARN << LC << "Failed to create graphic window too." << std::endl;
        }
    }

Member Function Documentation

bool MyGraphicsContext::valid ( ) const [inline]

Definition at line 60 of file osgearth_ocean.cpp.

{ return _gc.valid() && _gc->isRealized(); }

Here is the caller graph for this function:

bool MyGraphicsContext::valid ( ) const [inline]

Definition at line 89 of file Capabilities.cpp.

{ return _gc.valid() && _gc->isRealized(); }

Member Data Documentation

osg::ref_ptr< osg::GraphicsContext > MyGraphicsContext::_gc [private]

Definition at line 63 of file osgearth_ocean.cpp.


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines