Igor Naigovzin wrote: > Hello to all! > I have a simple question. > I want to render a two cameras (two different render surfaces) by exactly > the same scene.
Hi Igor, if I understand you correctly, you're doing the same sort of thing I am. I have a few cameras rendering to the same texture. This is the code I use: ref_ptr<GraphicsContext::Traits> traits = new GraphicsContext::Traits; traits->x = 500; traits->y = 800; traits->width = totalWidth; traits->height = vpHeight; traits->windowDecoration = true; traits->doubleBuffer = true; traits->sharedContext = 0; ref_ptr<GraphicsContext> _gc = GraphicsContext::createGraphicsContext(traits.get()); osgViewer::Viewer _viewer; for (int i = 0; i < _numCameras; ++i) { rot.makeRotate(_startAng + (_angStep * i), 0.0, 1.0, 0.0); ref_ptr<Camera> cam = new Camera; cam->setViewport(new Viewport(_cameraWidth * i, 0.0, _cameraWidth, _totalHeight)); cam->setRenderOrder(osg::Camera::PRE_RENDER); cam->setGraphicsContext(_gc); cam->setAllowEventFocus(false); cam->setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT); cam->attach(Camera::COLOR_BUFFER, _texture.get()); cam->setDataVariance(Object::DYNAMIC); cam->addChild(group.get()); _viewer.addSlave(cam.get(), Matrixd(), rot, false); } _viewer.getCamera()->setProjectionMatrixAsPerspective(_cameraFoVX / _aspectRatio, _aspectRatio, 1.0, 1000.0); _viewer.getCamera()->setViewMatrix(trans); _viewer.getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); _viewer.getCamera()->setClearColor(Vec4(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX)); _viewer.setDataVariance(Object::DYNAMIC); I'm using a floating-point texture, but it works just as well with a regular 8-bit RGB texture. Note I'm setting up the viewports for each camera. My application is a piecewise linear approximation of a cylindrical projection. I then set up another viewer and another scene graph to render the textured quad to the screen, then call _both_ viewers in my render loop. Hope this helps, -J ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org