Hi, I can not see hud camera text. I only see main camera output which is generated by osg Earth manipulator. This problem comes up with integration with Qt. Before integrating with Qt, this derived hud view example works great. I am sharing a sample of code. What is the reason that I could not see the text created with createText function. I think the problem is related to buffer bits again like in there http://forum.openscenegraph.org/viewtopic.php?t=17146
What should I do to solve this problem? Best regards, Code: void ExampleWidget::addText(osg::ref_ptr<osg::Geode> geode) { osg::Vec3 position( 200.0f, 25.0f, 0.0f); osgText::Text* text = new osgText::Text; std::string timesFont("fonts/arial.ttf"); text->setAlignment(osgText::TextBase::AlignmentType::LEFT_BOTTOM_BASE_LINE); text->setFont(timesFont); text->setPosition(position); text->setText("HELLO WORLD !!!!!"); text->setCharacterSize(50.0); geode->addDrawable( text ); } osg::ref_ptr<osg::Camera> ExampleWidget::createHUD() { // create a camera to set up the projection and model view matrices, and the subgraph to draw in the HUD osg::ref_ptr<osg::Camera> camera = new osg::Camera; // set the projection matrix camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024)); // set the view matrix camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setViewMatrix(osg::Matrix::identity()); // only clear the depth buffer camera->setClearMask( GL_COLOR_BUFFER_BIT ); // draw subgraph after main camera view. camera->setRenderOrder(osg::Camera::POST_RENDER); // we don't want the camera to grab event focus from the viewers main camera(s). camera->setAllowEventFocus(false); camera->getOrCreateStateSet()->setAttributeAndModes( new osg::Depth( osg::Depth::LEQUAL, 0.0, 0.0) ); return camera.get(); } ExampleWidget::ExampleWidget(QWidget* parent, Qt::WindowFlags f, osgViewer::ViewerBase::ThreadingModel threadingModel ) : QWidget(parent, f) { viewer = new osgViewer::Viewer; setThreadingModel( threadingModel ) ; setKeyEventSetsDone(0); QWidget* widget1 = create(); QGridLayout* grid = new QGridLayout; grid->addWidget( widget1, 0, 0 ); setLayout( grid ); connect( &_timer, SIGNAL(timeout()), this, SLOT(update()) ); _timer.start( 10 ); } QWidget* ExampleWidget::create( ) { osg::ArgumentParser arguments(&argc,argv); osg::ref_ptr<osg::Group> group = MapNodeHelper().load(arguments, viewer);//osg::ref_ptr<osg::Node> group = osgDB::readRefNodeFiles(arguments); manipulator = new EarthManipulator( /*arguments*/ ); viewer->setCameraManipulator( manipulator ); osgEarth::Config c; c.add("srs","wgs84"); c.add("vdatum","egm96"); c.add( "x", 39.0 ); c.add( "y", 32.0); c.add( "z", 1300 ); //c.add( "range", 0 ); c.add( "heading", 0.0 ); c.add( "pitch", -90.0 ); Viewpoint v; manipulator->zoom(0.0,0.0); manipulator->setHomeViewpoint( Viewpoint(c) ); osg::ref_ptr<osg::Camera> hudCamera = createHUD(); osg::ref_ptr<osg::Geode> geode = new osg::Geode(); // turn lighting off for the text and disable depth test to ensure it's always ontop. geode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); addText(geode); hudCamera->addChild(geode); hudCamera->setClearColor( osg::Vec4(255.0, 0.0, 0.0, 1.0) ); viewer->addEventHandler( new osgViewer::StatsHandler ); osgQt::GraphicsWindowQt* gw = createGraphicsWindow(0,0,500,500); const osg::GraphicsContext::Traits* traits = gw->getTraits(); osg::Viewport* wp = new osg::Viewport( 0, 0, traits->width, traits->height ); hudCamera->setGraphicsContext( gw ); hudCamera->setViewport( wp ); viewer->getCamera()->setGraphicsContext( gw ); viewer->getCamera()->setViewport( wp ); group->setDataVariance(osg::Object::DataVariance::STATIC); manipulator->setDataVariance( osg::Object::DataVariance::DYNAMIC ); osgUtil::Optimizer optimizer; optimizer.optimize(group.get()); viewer->addSlave(hudCamera, false); viewer->setSceneData(group); addView( viewer ); return gw->getGLWidget(); } ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=73108#73108 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org