Changed the use of a viewer thread to be off by default because it was causing the application to crash when any users input was recieved

This commit is contained in:
Robert Osfield 2011-03-09 10:35:00 +00:00
parent 3421cbbba1
commit 17f1f432f4
2 changed files with 19 additions and 12 deletions

View File

@ -86,8 +86,9 @@ int main(int argc, char **argv)
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
bool useFrameLoopThread = true;
bool useFrameLoopThread = false;
if (arguments.read("--no-frame-thread")) useFrameLoopThread = false;
if (arguments.read("--frame-thread")) useFrameLoopThread = true;
osg::ref_ptr<osgQt::QWebViewImage> image = new osgQt::QWebViewImage;

View File

@ -137,8 +137,9 @@ int main(int argc, char **argv)
// true = run osgViewer in a separate thread than Qt
// false = interleave osgViewer and Qt in the main thread
bool useFrameLoopThread = true;
if (arguments.read("--noFrameThread")) useFrameLoopThread = false;
bool useFrameLoopThread = false;
if (arguments.read("--no-frame-thread")) useFrameLoopThread = false;
if (arguments.read("--frame-thread")) useFrameLoopThread = true;
// true = use QWidgetImage
// false = use QWebViewImage
@ -376,10 +377,21 @@ int main(int argc, char **argv)
geode->addDrawable(quad);
osg::MatrixTransform* mt = new osg::MatrixTransform;
osg::Texture2D* texture = new osg::Texture2D(widgetImage.get());
texture->setResizeNonPowerOfTwoHint(false);
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
mt->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
osgViewer::InteractiveImageHandler* handler;
if (inScene)
{
mt->setMatrix(osg::Matrix::rotate(osg::Vec3(0,1,0), osg::Vec3(0,0,1)));
mt->addChild(geode);
handler = new osgViewer::InteractiveImageHandler(widgetImage.get());
}
else // fullscreen
{
@ -401,6 +413,8 @@ int main(int argc, char **argv)
camera->setViewport(0, 0, 1024, 768);
mt->addChild(camera);
handler = new osgViewer::InteractiveImageHandler(widgetImage.get(), texture, camera);
}
mt->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
@ -408,19 +422,11 @@ int main(int argc, char **argv)
mt->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
mt->getOrCreateStateSet()->setAttribute(new osg::Program);
osg::Texture2D* texture = new osg::Texture2D(widgetImage.get());
texture->setResizeNonPowerOfTwoHint(false);
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
mt->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
osg::Group* overlay = new osg::Group;
overlay->addChild(mt);
root->addChild(overlay);
osgViewer::InteractiveImageHandler* handler = new osgViewer::InteractiveImageHandler(widgetImage.get(), texture, camera);
quad->setEventCallback(handler);
quad->setCullCallback(handler);
}