Hi Vincent, I used to use a clearnode a while back.. All I do now with my mixed OpenGL and OSG is the following at setup..
All I do is the following.. sceneViewer->getCamera()->setClearMask(0); You can put various GL_DEPTH_BUFFER_BIT, and colour buffer bits and so on in the setClearMask to get your required level of clearing, or not.. Hope that helps, Stephen. On Jan 31, 2008, at 11:41 AM, Vincent wrote: > > I thought I was able to do this years ago and had it work alright, > so I > think I'm forgetting something...hopefully someone can help. > > I need to have my clearcolor and clear masks set outside of osg > glClear(...). If I set OSG;s viewport smaller than my main > viewport, I > can still see my scene is getting rendered behind OSG. Also, when I > use the > clearnode its setting OSG background to black(this is probably the > clue of > what I'm doing wrong). All I'm doing right now is rendering the > cow....nothing else. I am using the clearnode as shown below. > > /////////////This here is how I'm creating the viewer///////////// > sceneViewer_[0] = new osgUtil::SceneView(); > sceneViewer_[0]->setFrameStamp( frameStamp.get() ); > sceneViewer_[0]->setDefaults( osgUtil::SceneView::STANDARD_SETTINGS > ); > sceneViewer_[0]->setComputeNearFarMode( > osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR ); > > > ////////////This here is how I'm adding the > clearnode ///////////////////// > > osg::Node *loadedModel = > sgDB::readNodeFile("C:/Debug/cow.osg"); > > if (!loadedModel) > { > OutputDebugString("failed loading model"); > system("pause"); > } > > osg::ClearNode *clear_node = new osg::ClearNode(); > clear_node->setRequiresClear( false ); > osg::StateSet *stateset = new osg::StateSet(); > stateset->setMode( GL_RESCALE_NORMAL, > osg::StateAttribute::ON ); > osg::PositionAttitudeTransform *transform0 = new > osg::PositionAttitudeTransform; > transform0->setStateSet(stateset); > transform0->addChild( loadedModel ); > transform0->setPosition( osg::Vec3(0,0,0 ) ); > clear_node->addChild( transform0 ); > sceneViewer_[0]->setSceneData( clear_node ); > > > ///////////////This here is how I'm rendering///////////// > glPushAttrib( GL_ALL_ATTRIB_BITS ); > glMatrixMode( GL_PROJECTION ); > glPushMatrix(); > glMatrixMode( GL_TEXTURE ); > glPushMatrix(); > glMatrixMode( GL_MODELVIEW ); > glPushMatrix(); > > sceneViewer_[0]->setViewport(pCamera->viewParams[0], > pCamera->viewParams[1], pCamera->viewParams[2], pCamera- > >viewParams[3]); > > GLdouble glMat[16]; > osg::Matrixd osgMat; > glGetDoublev( GL_PROJECTION_MATRIX, glMat ); > osgMat.set( glMat ); > sceneViewer_[0]->getProjectionMatrix().set( osgMat ); > > > glGetDoublev( GL_MODELVIEW_MATRIX, glMat ); > osgMat.set( glMat ); > sceneViewer_[0]->getViewMatrix().set( osgMat ); > > > sceneViewer_[0]->update (); > sceneViewer_[0]->cull (); > sceneViewer_[0]->draw(); > > glMatrixMode(GL_MODELVIEW); > glPopMatrix(); > > glMatrixMode(GL_TEXTURE); > glPopMatrix(); > glMatrixMode(GL_PROJECTION); > glPopMatrix(); > glPopAttrib() > > > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.516 / Virus Database: 269.19.16/1251 - Release Date: > 1/30/2008 > 9:29 AM > > > _______________________________________________ > 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