Hi Philip and xbee We have this code and is working for us:
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::GraphicsContext* _gc= osg::GraphicsContext::createGraphicsContext(traits.get()); if (!_gc) { osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<<std::endl; traits->pbuffer = false; _gc = osg::GraphicsContext::createGraphicsContext(traits.get()); } v->getCamera()->setGraphicsContext(_gc); v->getCamera()->setViewport(new osg::Viewport(x,y,width,height)); v is an osgViewer::Viewer. Hope this helps. On Sun, Apr 27, 2008 at 7:49 PM, xbee <[EMAIL PROTECTED]> wrote: > Tessier, Philip a écrit : > > My attempt to use createGraphicsContext() to create an off-screen > > rendering context is failing. (It's returning NULL.) > > > > I'm using Win32. > > > > What am I missing? > > > > I have added the following to my code: > > osg::GraphicsContext * GetOffscreenGraphicsContext( > > unsigned a_tex_width, > > unsigned a_tex_height > > ) > > { > > osg::ref_ptr<osg::GraphicsContext::Traits> traits=new > > osg::GraphicsContext::Traits; > > > > traits->width = a_tex_width; > > traits->height = a_tex_height; > > // traits->doubleBuffer = true; > > traits->pbuffer = true; > > > > osg::ref_ptr<osg::GraphicsContext> > > gc=osg::GraphicsContext::createGraphicsContext(traits.get()); > > // TODO: Above returning NULL! > > > > return gc.get(); > > } > > > > with the following to hook it in: > > // Setup camera for off-screen rendering. > > osg::ref_ptr<osg::GraphicsContext> gc= > > GetOffscreenGraphicsContext( tex_width, tex_height); > > camera->setGraphicsContext(gc.get()); > > > > Thanks, > > Phil > > > > Hi, > Found any solution ? I've the same problem, I have a previous solution > with Producer but I want to port my snapshot application to 2.4 release > and I can't save any image without a viewer. Anyone have a solution ? > > Thanks > > -- > _ > /_/_ .'''. > =O(X)))) ...' `. > \_\ `. .''' > `..' > "Power corrupts. PowerPoint corrupts absolutely." > My personnal (french) Websites: http://www.xbee.net > and http://www.french-comics-zone.fr.st > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Rafael Gaitán Linares Instituto de Automática e Informática Industrial http://www.ai2.upv.es Ciudad Politécnica de la Innovación Universidad Politécnica de Valencia
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org