Canvas troubleshooting: Difference between revisions

Jump to navigation Jump to search
m
Line 755: Line 755:
}}
}}


With Canvas textures typically not rendering any scene/scenery data (terrain), we don't necessarily need those Cameras to render within the main viewer. This is intended to help better leverage OSG-level concurrency support by using a separate CompositeViewer instance to render Canvas textures, without having to change the main OSGViewer and its threading mode:
With Canvas textures typically not rendering any scene/scenery data (terrain), we don't necessarily need those Cameras to render within the main viewer, i.e. by settig up a CompositeViewer instance rendering to a pbuffer instead of a visible window [https://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg67926.html]:
 
<syntaxhighlight lang="cpp">
# #include <osgViewer/CompositeViewer>
 
...
 
osgViewer::CompositeViewer *v = new osgViewer::CompositeViewer;
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
 
traits->x =x;
traits->y = y;
traits->width = width;
traits->height = height;
traits->windowDecoration = false;
traits->doubleBuffer = false;
traits->sharedContext = 0;
traits->pbuffer = true;
 
osg::ref_ptr<osg::GraphicsContext> _gc= osg::GraphicsContext::createGraphicsContext(traits.get());
 
if (!_gc)
    {
        osg::notify(osg::NOTICE)<<"Failed to create pbuffer gc, failing back to normal graphics window."<<std::endl;
        traits->pbuffer = false;
        _gc = osg::GraphicsContext::createGraphicsContext(traits.get());
    }
v->getCamera()->setGraphicsContext(_gc.get());
v->getCamera()->setViewport(new osg::Viewport(x,y,width,height));
 
osgViewer::View* view = new osgViewer::View;
view->setName("Main Canvas View");
viewer.addView(view);
 
view->setUpViewOnSingleScreen(0);
 
//view->setSceneData(scene.get());
</syntaxhighlight>
 
This is intended to help better leverage OSG-level concurrency support by using a separate CompositeViewer instance to render Canvas textures, without having to change the main OSGViewer and its threading mode:


<syntaxhighlight lang="diff">
<syntaxhighlight lang="diff">
</syntaxhighlight>
</syntaxhighlight>

Navigation menu