Implement a GraphicsOperation to test extension availability
This commit is contained in:
parent
4d494c0014
commit
f405848380
@ -241,18 +241,22 @@ osg::Node* createScene()
|
||||
return scene;
|
||||
}
|
||||
|
||||
#if 0
|
||||
class TestSupportCallback : public osgProducer::OsgCameraGroup::RealizeCallback
|
||||
class TestSupportOperation: public osg::GraphicsOperation
|
||||
{
|
||||
public:
|
||||
TestSupportCallback():_supported(true),_errorMessage() {}
|
||||
|
||||
virtual void operator()( osgProducer::OsgCameraGroup&, osgProducer::OsgSceneHandler& sh, const Producer::RenderSurface& )
|
||||
{
|
||||
TestSupportOperation():
|
||||
osg::GraphicsOperation("TestSupportOperation",false),
|
||||
_supported(true),
|
||||
_errorMessage() {}
|
||||
|
||||
virtual void operator () (osg::GraphicsContext* gc)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Not called"<<std::endl;
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
|
||||
unsigned int contextID = sh.getSceneView()->getState()->getContextID();
|
||||
unsigned int contextID = gc->getState()->getContextID();
|
||||
osg::GL2Extensions* gl2ext = osg::GL2Extensions::Get(contextID,true);
|
||||
if( gl2ext )
|
||||
{
|
||||
@ -270,17 +274,16 @@ class TestSupportCallback : public osgProducer::OsgCameraGroup::RealizeCallback
|
||||
_errorMessage = "ERROR: vertex texturing not supported by OpenGL driver.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sh.init();
|
||||
_supported = false;
|
||||
_errorMessage = "ERROR: Pllalalal.";
|
||||
|
||||
}
|
||||
|
||||
OpenThreads::Mutex _mutex;
|
||||
bool _supported;
|
||||
std::string _errorMessage;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
@ -292,26 +295,28 @@ int main(int, char **)
|
||||
// add model to viewer.
|
||||
viewer.setSceneData( node );
|
||||
|
||||
#if 0
|
||||
// register a test extension callback to be called when app realizes and gets a valid graphics context
|
||||
osg::ref_ptr<TestSupportCallback> testSupportCallback = new TestSupportCallback();
|
||||
viewer.setRealizeCallback(testSupportCallback.get());
|
||||
viewer.setUpViewAcrossAllScreens();
|
||||
|
||||
osg::ref_ptr<TestSupportOperation> testSupportOperation = new TestSupportOperation;
|
||||
|
||||
osgViewer::Viewer::Windows windows;
|
||||
viewer.getWindows(windows);
|
||||
for(osgViewer::Viewer::Windows::iterator itr = windows.begin();
|
||||
itr != windows.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->add(testSupportOperation.get());
|
||||
}
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize();
|
||||
|
||||
// exit if we don't have the extensions this example needs.
|
||||
if (!testSupportCallback->_supported)
|
||||
if (!testSupportOperation->_supported)
|
||||
{
|
||||
osg::notify(osg::WARN)<<testSupportCallback->_errorMessage<<std::endl;
|
||||
osg::notify(osg::WARN)<<testSupportOperation->_errorMessage<<std::endl;
|
||||
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
|
||||
osg::notify(osg::NOTICE)<<"osgshaderterrain OpenGL support test not implemented yet"<<std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user