本文整理汇总了C++中osg::StateSet::compileGLObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ StateSet::compileGLObjects方法的具体用法?C++ StateSet::compileGLObjects怎么用?C++ StateSet::compileGLObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::StateSet
的用法示例。
在下文中一共展示了StateSet::compileGLObjects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void GLObjectsVisitor::apply(osg::StateSet& stateset)
{
if (_stateSetAppliedSet.count(&stateset)!=0) return;
_stateSetAppliedSet.insert(&stateset);
if (_mode & COMPILE_STATE_ATTRIBUTES && _renderInfo.getState())
{
stateset.compileGLObjects(*_renderInfo.getState());
osg::Program* program = dynamic_cast<osg::Program*>(stateset.getAttribute(osg::StateAttribute::PROGRAM));
if (program) {
if( program->isFixedFunction() )
_lastCompiledProgram = NULL; // It does not make sense to apply uniforms on fixed pipe
else
_lastCompiledProgram = program;
}
if (_lastCompiledProgram.valid() && !stateset.getUniformList().empty())
{
osg::Program::PerContextProgram* pcp = _lastCompiledProgram->getPCP(*_renderInfo.getState());
if (pcp)
{
pcp->useProgram();
_renderInfo.getState()->setLastAppliedProgramObject(pcp);
const osg::StateSet::UniformList& ul = stateset.getUniformList();
for(osg::StateSet::UniformList::const_iterator itr = ul.begin();
itr != ul.end();
++itr)
{
pcp->apply(*(itr->second.first));
}
}
}
else if(_renderInfo.getState()->getLastAppliedProgramObject())
{
osg::State* state = _renderInfo.getState();
osg::GLExtensions* extensions = state->get<osg::GLExtensions>();
extensions->glUseProgram(0);
_renderInfo.getState()->setLastAppliedProgramObject(0);
}
}
if (_mode & RELEASE_STATE_ATTRIBUTES)
{
stateset.releaseGLObjects(_renderInfo.getState());
}
if (_mode & CHECK_BLACK_LISTED_MODES)
{
stateset.checkValidityOfAssociatedModes(*_renderInfo.getState());
}
}