本文整理汇总了C++中VirtualProgram::referenceCount方法的典型用法代码示例。如果您正苦于以下问题:C++ VirtualProgram::referenceCount方法的具体用法?C++ VirtualProgram::referenceCount怎么用?C++ VirtualProgram::referenceCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualProgram
的用法示例。
在下文中一共展示了VirtualProgram::referenceCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
ShaderGenerator::processText(const osg::StateSet* ss, osg::ref_ptr<osg::StateSet>& replacement)
{
// do nothing if there's no GLSL support
if ( !_active )
return false;
// State object with extra accessors:
StateEx* state = static_cast<StateEx*>(_state.get());
// check for a real osg::Program. If it exists, bail out so that OSG
// can use the program already in the graph
osg::StateAttribute* program = state->getAttribute(osg::StateAttribute::PROGRAM);
if ( dynamic_cast<osg::Program*>(program) != 0L )
return false;
// new state set:
replacement = ss ? osg::clone(ss, osg::CopyOp::SHALLOW_COPY) : new osg::StateSet();
// new VP:
VirtualProgram* vp = 0L;
if ( VirtualProgram::get(replacement.get()) )
vp = osg::clone(VirtualProgram::get(replacement.get()), osg::CopyOp::DEEP_COPY_ALL);
else
vp = VirtualProgram::getOrCreate(replacement.get());
if ( vp->referenceCount() == 1 )
vp->setName( _name );
std::string vertSrc =
"#version " GLSL_VERSION_STR "\n" GLSL_PRECISION "\n"
"varying " MEDIUMP "vec4 " TEX_COORD_TEXT ";\n"
"void " VERTEX_FUNCTION "(inout vec4 vertexVIEW)\n"
"{ \n"
INDENT TEX_COORD_TEXT " = gl_MultiTexCoord0;\n"
"} \n";
std::string fragSrc =
"#version " GLSL_VERSION_STR "\n" GLSL_PRECISION "\n"
"uniform sampler2D " SAMPLER_TEXT ";\n"
"varying " MEDIUMP "vec4 " TEX_COORD_TEXT ";\n"
"void " FRAGMENT_FUNCTION "(inout vec4 color)\n"
"{ \n"
INDENT MEDIUMP "vec4 texel = texture2D(" SAMPLER_TEXT ", " TEX_COORD_TEXT ".xy);\n"
INDENT "color.a *= texel.a; \n"
"}\n";
vp->setFunction( VERTEX_FUNCTION, vertSrc, ShaderComp::LOCATION_VERTEX_VIEW );
vp->setFunction( FRAGMENT_FUNCTION, fragSrc, ShaderComp::LOCATION_FRAGMENT_COLORING );
replacement->getOrCreateUniform( SAMPLER_TEXT, osg::Uniform::SAMPLER_2D )->set( 0 );
return replacement.valid();
}
示例2: apply
void
ShaderGenerator::apply(osg::ClipNode& node)
{
static const char* s_clip_source =
"#version " GLSL_VERSION_STR "\n"
"void oe_sg_set_clipvertex(inout vec4 vertexVIEW)\n"
"{\n"
" gl_ClipVertex = vertexVIEW; \n"
"}\n";
if ( !_active ) return;
VirtualProgram* vp = VirtualProgram::getOrCreate(node.getOrCreateStateSet());
if ( vp->referenceCount() == 1 ) vp->setName( _name );
vp->setFunction( "oe_sg_set_clipvertex", s_clip_source, ShaderComp::LOCATION_VERTEX_VIEW );
apply( static_cast<osg::Group&>(node) );
}