|
楼主 |
发表于 2015-6-26 11:54:22
|
显示全部楼层
谢谢了!
osg::Group* pTextGroup = new osg::Group;
pTextGroup->setName(Floor.m_strFloorName + std::string("TEXT"));
pTextGroup->getOrCreateStateSet()->setAttribute(textShaderProgram);
osg::Uniform* baseTextureSampler1 = new osg::Uniform("baseTexture",0);
pTextGroup->getOrCreateStateSet()->addUniform(baseTextureSampler1);
pTextGroup->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);//关闭灯光
osg::Geode* pTextGeode = new osg::Geode;
osgText::Text* text = new osgText::Text;
text->setFont(font,false);
text->setColor(osg::Vec4(1, 0, 0, 1));
text->setCharacterSize(30.f,false);
text->setCharacterSize(40);
text->setFontResolution(120, 120,false);
text->setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
text->setPosition(pos);
text->setAxisAlignment(osgText::Text::SCREEN);
text->setAlignment(osgText::Text::CENTER_CENTER,false);
text->setText(strText,osgText::String::ENCODING_UTF8, false);
text->setMaximumWidth(fWidth, false);
text->update();
pTextGeode->setName(strText.c_str());
pTextGeode->addDrawable(text);
pTextGroup->addChild(pTextGeode);
我在群里问过了,说是要关闭灯光才可以,红色部分是关闭灯光的操作,是我写的不对还是其他问题,还请大家指点,谢谢 |
|