I have to write a series of classes wrapping OSG model, which loads OSG graph from an .osg file, uses some data from it, saves the scene back to .osg file etc.
I can't find out how (if it's possible) to render an OSG graph into an image file. So, what i am trying to do is: void renderSceneToImage(::osg::Node* pNode, const ::std::string& sFileName_, <some camera parameteres here>) The function should take the root node of the OSG scene, render it ONCE to an image (::osg::Image?) and then save the image into the file. I don't need to open any windows. >From what I found on the net so far: //---------------------------------------------------- ::osg::Image* capImage = new ::osg::Image(); capImage->allocateImage(nWidth, nHeight, 1, GL_RGBA, GL_FLOAT); capImage->setInternalTextureFormat(GL_RGBA16F_ARB); ::osg::ref_ptr< ::osg::Camera> camera = new ::osg::Camera(); camera->setRenderTargetImplementation(::osg::CameraNode::FRAME_BUFFER_OBJECT); camera->setRenderOrder(::osg::Camera::PRE_RENDER); camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); camera->setViewport(0, 0, nWidth, nHeight); camera->attach(::osg::CameraNode::COLOR_BUFFER, capImage); // temporarily wrap the whole scene with camera camera->addChild(pScene->root()); ::osg::ref_ptr< ::osg::Group> tempRoot = new ::osg::Group(); tempRoot->addChild(camera.get()); // HOW TO ORDER THE CAMERA TO RENDER? ::osgDB::writeImageFile(*capImage, sFileName_); //------------------------------------------------- So, i can't find any way to order the camera to render once. All examples show how to make the camera render to a texture, but when it renders is decided by OpenGL (?). I don't need all that, i just need to grab the picture once and return. Is this possible with OSG? Thanks! ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33809#33809 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

