1

In my OpenSceneGraph program, I have the following code:

osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();

    if (!wsi) {
        osg::notify(osg::NOTICE) << "Error, no WindowingSystemInterface available, cannot create windows." << std::endl;
        return 0;
    }

Unfortunately the method getWindowingSystemInterface() returns a null value, so the program cannot continue. What can be the reason that it returns null and how can I change my program (or build settings?) to let it return a non-null value? I'm using Visual Studio 2012.

Roalt
  • 8,330
  • 7
  • 41
  • 53

1 Answers1

0

It's possible you are querying the interface before it has been created, so it returns a null. If you are running with a console window, try setting OSG_NOTIFY_LEVEL environment variable to either INFO or DEBUG, and it will tell you exactly if/when it sets the windowing interface.

See the "set" method (from 3.1.3 dev build anyways), which performs a print if your notify level is INFO or higher:

void GraphicsContext::setWindowingSystemInterface(WindowingSystemInterface* callback)
{
    ref_ptr<GraphicsContext::WindowingSystemInterface> &wsref = windowingSystemInterfaceRef();
    wsref = callback;
    OSG_INFO<<"GraphicsContext::setWindowingSystemInterface() "<<wsref.get()<<"\t"<<&wsref<<std::endl;
}

http://www.openscenegraph.com/index.php/documentation/debugging-tips

Ruan Caiman
  • 881
  • 5
  • 5