Hi Mukend, If you are creating your own viewer cameras and associated graphics contexts then you don't need to call any of the setUpView*() methods, otherwise you will just end up with the windows and camera it creates and the ones you create.
Also when you are not using quad buffer stereo the draw/read buffers of the camera should just be set the GL_BACK. Robert. On Tue, Mar 29, 2011 at 9:06 PM, Mukund Keshav <osgfo...@tevs.eu> wrote: > Hi Robert, > > Well this is the code i have written so far, im getting two windows when i > specify quadBufferStereo as false. > > > Code: > int main( int argc, char **argv ) > { > > // if not loaded assume no arguments passed in, try use default mode > instead. > osg::ref_ptr<osg::MatrixTransform> object = new osg::MatrixTransform; > osg::ref_ptr<osg::Node> obj = osgDB::readNodeFile("cow.osg"); > object->addChild(obj); > > // > ============================================================================= > // construct the viewer. > osgViewer::Viewer viewer; > > > viewer.setUpViewInWindow(100, 100, 640, 480); > // > ============================================================================== > > > // > ============================================================================== > // Place the object. > osg::Matrix m, s; > m.makeTranslate(0, 0, -4000); > s.makeScale(50, 50, 50); > > object->setMatrix(osg::Matrix::identity()); > object->setMatrix(s * m); > // > ============================================================================== > > > osg::ref_ptr<osg::GraphicsContext::Traits> traits = new > osg::GraphicsContext::Traits; > traits->width = 640; > traits->height = 480; > traits->windowDecoration = true; > traits->doubleBuffer = true; > traits->sharedContext = 0; > //traits->quadBufferStereo = true; > > osg::ref_ptr<osg::GraphicsContext> gc = > osg::GraphicsContext::createGraphicsContext(traits.get()); > > // ========================= Left eye > ==================================================== > osg::ref_ptr<osg::Camera> camera = new osg::Camera; > osg::Matrix lookPos1; > > lookPos1.lookAt( osg::Vec3f(0, 0, 8000), osg::Vec3f(0, 0, 0), > osg::Vec3f(0, 1, 0) ); > > camera->setViewMatrix(osg::Matrix::identity()); > camera->setViewMatrix(lookPos1); > camera->setViewport(0, 0, 640, 480); > > camera->setGraphicsContext(gc.get()); > camera->setDrawBuffer(GL_BACK_LEFT); > > camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); > camera->setProjectionMatrixAsFrustum(-640, 640, -480, 480, 1900, > 200000); > > osg::ColorMask *col1 = new osg::ColorMask; > col1->setRedMask(true); > osg::StateSet *state1 = new osg::StateSet; > state1->setAttribute(col1); > > camera->setStateSet(state1); > > // add this slave camera to the viewer, with a shift left of the > projection matrix > viewer.addSlave(camera.get(), osg::Matrixd::translate(params), > osg::Matrixd()); > > > // ========================= Right eye > ==================================================== > osg::ref_ptr<osg::Camera> camera1 = new osg::Camera; > osg::Matrix lookPos2; > > lookPos2.lookAt( osg::Vec3f(0, 0, 8000), osg::Vec3f(0, 0, 0), > osg::Vec3f(0, 1, 0) ); > > camera1->setViewMatrix(osg::Matrix::identity()); > camera1->setViewMatrix(lookPos2); > camera1->setViewport(0, 0, 640, 480); > > camera1->setGraphicsContext(gc.get()); > camera1->setDrawBuffer(GL_BACK_RIGHT); > > camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); > camera1->setProjectionMatrixAsFrustum(-640, 640, -480, 480, 1900, > 200000); > > osg::ColorMask *col2 = new osg::ColorMask; > col2->setRedMask(true); > osg::StateSet *state2 = new osg::StateSet; > state1->setAttribute(col2); > > camera1->setStateSet(state2); > > > // add this slave camera to the viewer, with a shift right of the > projection matrix > viewer.addSlave(camera1.get(), osg::Matrixd::translate(params), > osg::Matrixd()); > > // > =========================================================================================== > > > // set the scene to render > viewer.setSceneData(object.get()); > > viewer.run(); > > } > > > > > > Here is a snapshot of the output: im not sure where i'm going wrong. The cow > model appears black. > > http://img220.imageshack.us/i/88575177.png/ > > Also, im getting the following warning: > detected OpenGL error , invalid operation , after RenderBin::draw(,) > > Could you please help? > > Thanks, > Mukund > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=38037#38037 > > > > > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org