| 616 | | |
|---|
| 617 | | osg::Group* textGroup = new osg::Group; |
|---|
| 618 | | mainGroup->addChild(textGroup); |
|---|
| 619 | | |
|---|
| 620 | | // create the background thread |
|---|
| 621 | | operationThread = new osg::OperationThread; |
|---|
| 622 | | |
|---|
| 623 | | // create the operation that will run in the background and |
|---|
| 624 | | // sync once per frame with the main viewer loop. |
|---|
| 625 | | updateOperation = new UpdateTextOperation(textGroup); |
|---|
| 626 | | |
|---|
| 627 | | // add the operation to the operation thread and start it. |
|---|
| 628 | | operationThread->add(updateOperation.get()); |
|---|
| 629 | | operationThread->startThread(); |
|---|
| 630 | | |
|---|
| 631 | | // add the operation to the viewer to sync once per frame. |
|---|
| 632 | | viewer.addUpdateOperation(updateOperation.get()); |
|---|
| 633 | | |
|---|
| 634 | | |
|---|
| 635 | | // add a unit cube for the text to appear within. |
|---|
| 636 | | osg::Geode* geode = new osg::Geode; |
|---|
| 637 | | geode->getOrCreateStateSet()->setAttribute(new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE)); |
|---|
| 638 | | geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.5f,0.5f,0.5f),1.0))); |
|---|
| 639 | | |
|---|
| 640 | | mainGroup->addChild(geode); |
|---|
| 641 | | |
|---|
| | 620 | |
|---|
| | 621 | for(unsigned int i=0; i<numThreads; ++i) |
|---|
| | 622 | { |
|---|
| | 623 | osg::Group* textGroup = new osg::Group; |
|---|
| | 624 | mainGroup->addChild(textGroup); |
|---|
| | 625 | |
|---|
| | 626 | // create the background thread |
|---|
| | 627 | osg::OperationThread* operationThread = new osg::OperationThread; |
|---|
| | 628 | |
|---|
| | 629 | operationThreads.push_back(operationThread); |
|---|
| | 630 | |
|---|
| | 631 | // create the operation that will run in the background and |
|---|
| | 632 | // sync once per frame with the main viewer loop. |
|---|
| | 633 | updateOperation = new UpdateTextOperation(textGroup); |
|---|
| | 634 | |
|---|
| | 635 | // add the operation to the operation thread and start it. |
|---|
| | 636 | operationThread->add(updateOperation.get()); |
|---|
| | 637 | operationThread->startThread(); |
|---|
| | 638 | |
|---|
| | 639 | // add the operation to the viewer to sync once per frame. |
|---|
| | 640 | viewer.addUpdateOperation(updateOperation.get()); |
|---|
| | 641 | |
|---|
| | 642 | |
|---|
| | 643 | // add a unit cube for the text to appear within. |
|---|
| | 644 | osg::Geode* geode = new osg::Geode; |
|---|
| | 645 | geode->getOrCreateStateSet()->setAttribute(new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE)); |
|---|
| | 646 | geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.5f,0.5f,0.5f),1.0))); |
|---|
| | 647 | |
|---|
| | 648 | mainGroup->addChild(geode); |
|---|
| | 649 | } |
|---|
| | 650 | |
|---|