- Timestamp:
- 11/17/05 21:22:55 (8 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgblendequation/osgblendequation.cpp
r4739 r4805 14 14 const osg::BlendEquation::Equation _equations[_eq_nb]= 15 15 { 16 osg::BlendEquation::FUNC_ADD,17 osg::BlendEquation::FUNC_SUBTRACT,18 osg::BlendEquation::FUNC_REVERSE_SUBTRACT,19 osg::BlendEquation::RGBA_MIN,20 osg::BlendEquation::RGBA_MAX,21 osg::BlendEquation::ALPHA_MIN,22 osg::BlendEquation::ALPHA_MAX,23 osg::BlendEquation::LOGIC_OP16 osg::BlendEquation::FUNC_ADD, 17 osg::BlendEquation::FUNC_SUBTRACT, 18 osg::BlendEquation::FUNC_REVERSE_SUBTRACT, 19 osg::BlendEquation::RGBA_MIN, 20 osg::BlendEquation::RGBA_MAX, 21 osg::BlendEquation::ALPHA_MIN, 22 osg::BlendEquation::ALPHA_MAX, 23 osg::BlendEquation::LOGIC_OP 24 24 }; 25 25 26 26 const char* _equations_name[_eq_nb]= 27 27 { 28 "osg::BlendEquation::FUNC_ADD",29 "osg::BlendEquation::FUNC_SUBTRACT",30 "osg::BlendEquation::FUNC_REVERSE_SUBTRACT",31 "osg::BlendEquation::RGBA_MIN",32 "osg::BlendEquation::RGBA_MAX",33 "osg::BlendEquation::ALPHA_MIN",34 "osg::BlendEquation::ALPHA_MAX",35 "osg::BlendEquation::LOGIC_OP"28 "osg::BlendEquation::FUNC_ADD", 29 "osg::BlendEquation::FUNC_SUBTRACT", 30 "osg::BlendEquation::FUNC_REVERSE_SUBTRACT", 31 "osg::BlendEquation::RGBA_MIN", 32 "osg::BlendEquation::RGBA_MAX", 33 "osg::BlendEquation::ALPHA_MIN", 34 "osg::BlendEquation::ALPHA_MAX", 35 "osg::BlendEquation::LOGIC_OP" 36 36 }; 37 37 … … 58 58 TechniqueEventHandler(const TechniqueEventHandler&,const osg::CopyOp&) {} 59 59 60 osg::BlendEquation* _blendEq;61 62 int _eq_index;60 osg::BlendEquation* _blendEq; 61 62 int _eq_index; 63 63 }; 64 64 65 65 66 66 67 67 68 68 bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&) 69 69 { … … 75 75 ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Right) 76 76 { 77 _eq_index++; 78 if (_eq_index>=_eq_nb) 79 _eq_index=0; 80 _blendEq->setEquation(_equations[_eq_index]); 81 std::cout<<"Equation name = "<<_equations_name[_eq_index]<<std::endl; 77 _eq_index++; 78 if (_eq_index>=_eq_nb) _eq_index=0; 79 _blendEq->setEquation(_equations[_eq_index]); 80 std::cout<<"Equation name = "<<_equations_name[_eq_index]<<std::endl; 82 81 return true; 83 82 } … … 85 84 ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Left) 86 85 { 87 _eq_index--; 88 if (_eq_index<0) 89 _eq_index=_eq_nb-1; 90 _blendEq->setEquation(_equations[_eq_index]); 91 std::cout<<"Operation name = "<<_equations_name[_eq_index]<<std::endl; 86 _eq_index--; 87 if (_eq_index<0) _eq_index=_eq_nb-1; 88 _blendEq->setEquation(_equations[_eq_index]); 89 std::cout<<"Operation name = "<<_equations_name[_eq_index]<<std::endl; 92 90 return true; 93 91 } … … 135 133 136 134 137 osg::StateSet* stateset =new osg::StateSet;138 osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::BlendEquation::FUNC_ADD);139 135 osg::StateSet* stateset = new osg::StateSet; 136 osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::BlendEquation::FUNC_ADD); 137 140 138 stateset->setAttributeAndModes(blendEquation,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); 141 139 142 140 //tell to sort the mesh before displaying it 143 141 stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); 144 142 145 143 146 144 loadedModel->setStateSet(stateset); … … 203 201 // fire off the cull and draw traversals of the scene. 204 202 viewer.frame(); 205 206 207 203 208 204 }
