Changeset 1937 for OpenSceneGraph/trunk/examples/osghud/osghud.cpp
- Timestamp:
- 05/06/03 20:04:27 (10 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/examples/osghud/osghud.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osghud/osghud.cpp
r1928 r1937 21 21 #include <osg/Depth> 22 22 #include <osg/Projection> 23 #include <osg/PolygonOffset> 23 24 #include <osg/MatrixTransform> 24 25 … … 30 31 osg::Geode* geode = new osg::Geode(); 31 32 32 std::string timesFont("fonts/ times.ttf");33 std::string timesFont("fonts/arial.ttf"); 33 34 34 35 // turn lighting off for the text and disable depth test to ensure its always ontop. 35 36 osg::StateSet* stateset = geode->getOrCreateStateSet(); 36 37 stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 37 stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); 38 //stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); 39 stateset->setAttribute(new osg::Depth(osg::Depth::LESS,0.0,0.0001)); 38 40 39 41 osg::Vec3 position(150.0f,800.0f,0.0f); … … 95 97 96 98 position += delta; 97 } 99 } 100 101 102 103 { 104 osg::BoundingBox bb; 105 for(unsigned int i=0;i<geode->getNumDrawables();++i) 106 { 107 bb.expandBy(geode->getDrawable(i)->getBound()); 108 } 109 110 osg::Geometry* geom = new osg::Geometry; 111 112 osg::Vec3Array* vertices = new osg::Vec3Array; 113 float depth = bb.zMin()-0.1; 114 vertices->push_back(osg::Vec3(bb.xMin(),bb.yMax(),depth)); 115 vertices->push_back(osg::Vec3(bb.xMin(),bb.yMin(),depth)); 116 vertices->push_back(osg::Vec3(bb.xMax(),bb.yMin(),depth)); 117 vertices->push_back(osg::Vec3(bb.xMax(),bb.yMax(),depth)); 118 geom->setVertexArray(vertices); 119 120 osg::Vec3Array* normals = new osg::Vec3Array; 121 normals->push_back(osg::Vec3(0.0f,0.0f,1.0f)); 122 geom->setNormalArray(normals); 123 geom->setNormalBinding(osg::Geometry::BIND_OVERALL); 124 125 osg::Vec4Array* colors = new osg::Vec4Array; 126 colors->push_back(osg::Vec4(1.0f,1.0,0.8f,0.2f)); 127 geom->setColorArray(colors); 128 geom->setColorBinding(osg::Geometry::BIND_OVERALL); 129 130 geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); 131 132 osg::StateSet* stateset = geom->getOrCreateStateSet(); 133 stateset->setMode(GL_BLEND,osg::StateAttribute::ON); 134 //stateset->setAttribute(new osg::PolygonOffset(1.0f,1.0f),osg::StateAttribute::ON); 135 stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); 136 137 geode->addDrawable(geom); 138 } 98 139 99 140 // create the hud. … … 167 208 // create the windows and run the threads. 168 209 viewer.realize(); 210 211 // set all the sceneview's up so that their left and right add cull masks are set up. 212 for(osgProducer::OsgCameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin(); 213 itr!=viewer.getSceneHandlerList().end(); 214 ++itr) 215 { 216 osgUtil::SceneView* sceneview = itr->get(); 217 sceneview->setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR); 218 } 219 169 220 170 221 while( !viewer.done() )
