|
贴一个 bmp的图片 好好的。贴2个就什么都不见了,代码如下
///创建 geode
osg::Geode* geode = new osg::Geode;
osg::Geometry* geom = new osg::Geometry;
geode->addDrawable(geom);
osg::Vec3Array* coords = new osg::Vec3Array(4);
(*coords)[0] = corner;
(*coords)[1] = corner+width;
(*coords)[2] = corner+width+height;
(*coords)[3] = corner+height;
geom->setVertexArray(coords);
osg::Vec3Array* norms = new osg::Vec3Array(1);
(*norms)[0] = width^height;
(*norms)[0].normalize();
geom->setNormalArray(norms);
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
osg::Vec2Array* tcoords = new osg::Vec2Array(4);
(*tcoords)[0].set(0.0f,0.0f);
(*tcoords)[1].set(1.0f,0.0f);
(*tcoords)[2].set(1.0f,1.0f);
(*tcoords)[3].set(0.0f,1.0f);
geom->setTexCoordArray(0,tcoords); //
geom->setTexCoordArray(1,tcoords);
geom->addPrimitiveSet(new osg:rawArrays(osg:rimitiveSet:UADS,0,4));
osg::Texture2D* Texture1= new osg::Texture2D;
osg::Texture2D* Texture2= new osg::Texture2D;
Texture1->setImage(osgDB::readImageFile("Halo3.bmp"));
Texture2->setImage(osgDB::readImageFile("Streaks4.bmp"));
osg::StateSet* stateOne = new osg::StateSet();
stateOne->setTextureAttributeAndModes(0,Texture1,osg::StateAttribute::ON);
//stateOne->setTextureAttributeAndModes(1,Texture2,osg::StateAttribute::ON); 用这行 就什么都没有
stateOne->setAttributeAndModes(new osg::BlendFunc(osg::BlendFunc::ONE ,osg::BlendFunc::SRC_ALPHA));
stateOne->setMode(GL_BLEND,osg::StateAttribute::ON);
stateOne->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
geode->setStateSet(stateOne); |
|