Can somebody do a test for me? I'm using OSG 3.0.0 and this works with NVIDIA
Driver (Linux) 260.19.21 but doesn't seem to work with newer versions of the
driver (e.g. 275.31 beta) with no other changes being made. I've been in
contact with NVIDIA with this problem and they seem to think that it is an OSG
problem.
I'm having trouble when I create an osgViewer, destroy it, restart the X server
and then create the osgViewer. I've boiled my problem down to a small test
case in the attached file which is a slightly modified version of osgviewer.
I know this test case is somewhat convoluted but bare with me. Our application
is required to restart the X server before starting to display an image.
Normally, osgviewer would do the following:
1) osgViewer::Viewer viewer(arguments);
2) viewer.setSceneData( loadedModel.get() );
3) viewer.realize();
4) viewer.run();
5) exit(0);
I have modified it to do the following:
Code:
while (forever)
{
{ // Define a scope of the osgViewer::Viewer
osgViewer::Viewer viewer(arguments);
viewer.setSceneData( loadedModel.get() );
viewer.realize();
viewer.run();
} // osgViewer::Viewer scope has ended and its destructor called.
sleep(2);
system(“/usr/sbin/gdm-restart”);
sleep(20);
}
Compile and run this program. Since this program restarts the X server (with
the gdm-restart command) and attempts to display an image, you will need use
two machines (a remote machine and a target machine). Running this using one
machine will cause the program to be killed when the X server is restarted. To
run this program, do the following:
> a. On the console of the target machine, login normally. Open a terminal
> window and type “xhost +”
> b. From a remote computer login to your target machine and “setenv DISPLAY
> :0.0” to keep the display on the remote machine.
> c. From this remote computer window, run the attached version of osgviewer as
> “osgviewer cow.osg”.
> d. Hit the escape key on the target machine to dismiss the cow being
> displayed.
> e. At this point, the target machine X server will restart. IMMEDIATELY after
> the X server has restarted, login to the target machine again from its
> console. Open a terminal window and select “xhost +” again. It you don't do
> this last part, you will not have permissions to display an image on the
> target machine from the remote machine. The program will give you 20 second
> before it attempts to display an image on on the target machine.
> f. At this point, you should see a cow image on the display but with this new
> driver, we’ve been seeing a totally black image.
When I run this program, instead of seeing the cow image the second time, I'm
seeing a black screen. I didn't see this problem with earlier version of the
NVIDIA driver (also using OSG 3.0.0).
Is anybody else having this problem?
Paul P.
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=43865#43865
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commercial and non commercial
applications,
* as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <osgDB/ReadFile>
#include <osgUtil/Optimizer>
#include <osg/CoordinateSystemNode>
#include <osg/Switch>
#include <osgText/Text>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TerrainManipulator>
#include <osgGA/SphericalManipulator>
#include <iostream>
int main(int argc, char** argv)
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+"
is the standard OpenSceneGraph example which loads and visualises 3d models.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+"
[options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("--image
<filename>","Load an image and render it on a quad");
arguments.getApplicationUsage()->addCommandLineOption("--dem
<filename>","Load an image/DEM and render it on a HeightField");
arguments.getApplicationUsage()->addCommandLineOption("--login <url>
<username> <password>","Provide authentication information for http file
access.");
unsigned int helpType = 0;
if ((helpType = arguments.readHelpType()))
{
arguments.getApplicationUsage()->write(std::cout, helpType);
return 1;
}
// report any errors if they have occurred when parsing the program
arguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
std::string url, username, password;
while(arguments.read("--login",url, username, password))
{
if (!osgDB::Registry::instance()->getAuthenticationMap())
{
osgDB::Registry::instance()->setAuthenticationMap(new
osgDB::AuthenticationMap);
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}
}
while(1)
{
{
osgViewer::Viewer viewer(arguments);
// set up the camera manipulators.
{
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator>
keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new
osgGA::TrackballManipulator() );
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new
osgGA::FlightManipulator() );
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new
osgGA::DriveManipulator() );
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new
osgGA::TerrainManipulator() );
keyswitchManipulator->addMatrixManipulator( '5', "Orbit", new
osgGA::OrbitManipulator() );
keyswitchManipulator->addMatrixManipulator( '6', "FirstPerson",
new osgGA::FirstPersonManipulator() );
keyswitchManipulator->addMatrixManipulator( '7', "Spherical", new
osgGA::SphericalManipulator() );
std::string pathfile;
double animationSpeed = 1.0;
while(arguments.read("--speed",animationSpeed) ) {}
char keyForAnimationPath = '8';
while (arguments.read("-p",pathfile))
{
osgGA::AnimationPathManipulator* apm = new
osgGA::AnimationPathManipulator(pathfile);
if (apm || !apm->valid())
{
apm->setTimeScale(animationSpeed);
unsigned int num =
keyswitchManipulator->getNumMatrixManipulators();
keyswitchManipulator->addMatrixManipulator(
keyForAnimationPath, "Path", apm );
keyswitchManipulator->selectMatrixManipulator(num);
++keyForAnimationPath;
}
}
viewer.setCameraManipulator( keyswitchManipulator.get() );
}
// add the state manipulator
viewer.addEventHandler( new
osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
// add the thread model handler
viewer.addEventHandler(new osgViewer::ThreadingHandler);
// add the window size toggle handler
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
// add the stats handler
viewer.addEventHandler(new osgViewer::StatsHandler);
// add the help handler
viewer.addEventHandler(new
osgViewer::HelpHandler(arguments.getApplicationUsage()));
// add the record camera path handler
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
// add the LOD Scale handler
viewer.addEventHandler(new osgViewer::LODScaleHandler);
// add the screen capture handler
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
// load the data
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
std::cout << arguments.getApplicationName() <<": No data loaded"
<< std::endl;
return 1;
}
// any option left unread are converted into errors to write out
later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occurred when parsing the program
arguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// optimize the scene graph, remove redundant nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get());
viewer.setSceneData( loadedModel.get() );
viewer.realize();
viewer.run();
}
sleep(2);
system("/usr/sbin/gdm-restart");
sleep(20);
}
return;
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org