From f405848380853e317706a49f8ccf25379dc61fab Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 12 Jan 2007 10:28:36 +0000 Subject: [PATCH] Implement a GraphicsOperation to test extension availability --- .../osgshaderterrain/osgshaderterrain.cpp | 103 +++++++++--------- 1 file changed, 54 insertions(+), 49 deletions(-) diff --git a/examples/osgshaderterrain/osgshaderterrain.cpp b/examples/osgshaderterrain/osgshaderterrain.cpp index d8f756e7c..ce879c29d 100644 --- a/examples/osgshaderterrain/osgshaderterrain.cpp +++ b/examples/osgshaderterrain/osgshaderterrain.cpp @@ -241,46 +241,49 @@ 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& ) +public: + + TestSupportOperation(): + osg::GraphicsOperation("TestSupportOperation",false), + _supported(true), + _errorMessage() {} + + virtual void operator () (osg::GraphicsContext* gc) + { + osg::notify(osg::NOTICE)<<"Not called"< lock(_mutex); + + unsigned int contextID = gc->getState()->getContextID(); + osg::GL2Extensions* gl2ext = osg::GL2Extensions::Get(contextID,true); + if( gl2ext ) { + if( !gl2ext->isGlslSupported() ) { - OpenThreads::ScopedLock lock(_mutex); - - unsigned int contextID = sh.getSceneView()->getState()->getContextID(); - osg::GL2Extensions* gl2ext = osg::GL2Extensions::Get(contextID,true); - if( gl2ext ) - { - if( !gl2ext->isGlslSupported() ) - { - _supported = false; - _errorMessage = "ERROR: GLSL not supported by OpenGL driver."; - } - - GLint numVertexTexUnits = 0; - glGetIntegerv( GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &numVertexTexUnits ); - if( numVertexTexUnits <= 0 ) - { - _supported = false; - _errorMessage = "ERROR: vertex texturing not supported by OpenGL driver."; - } - } + _supported = false; + _errorMessage = "ERROR: GLSL not supported by OpenGL driver."; + } + + GLint numVertexTexUnits = 0; + glGetIntegerv( GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &numVertexTexUnits ); + if( numVertexTexUnits <= 0 ) + { + _supported = false; + _errorMessage = "ERROR: vertex texturing not supported by OpenGL driver."; } - - sh.init(); } + + _supported = false; + _errorMessage = "ERROR: Pllalalal."; + + } - OpenThreads::Mutex _mutex; - bool _supported; - std::string _errorMessage; - + 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 = new TestSupportCallback(); - viewer.setRealizeCallback(testSupportCallback.get()); + viewer.setUpViewAcrossAllScreens(); + + osg::ref_ptr 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) - { - osg::notify(osg::WARN)<_errorMessage<_supported) + { + osg::notify(osg::WARN)<_errorMessage<