本文整理汇总了C++中colorfilterchain::const_iterator类的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_iterator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Shader
osg::Shader*
ShaderFactory::createColorFilterChainFragmentShader( const std::string& function, const ColorFilterChain& chain ) const
{
std::stringstream buf;
buf << "#version " << GLSL_VERSION_STR << "\n"
<< PRECISION_MEDIUMP_FLOAT << "\n";
// write out the shader function prototypes:
for( ColorFilterChain::const_iterator i = chain.begin(); i != chain.end(); ++i )
{
ColorFilter* filter = i->get();
buf << "void " << filter->getEntryPointFunctionName() << "(in int slot, inout vec4 color);\n";
}
// write out the main function:
buf << "void " << function << "(in int slot, inout vec4 color) \n"
<< "{ \n";
// write out the function calls. if there are none, it's a NOP.
for( ColorFilterChain::const_iterator i = chain.begin(); i != chain.end(); ++i )
{
ColorFilter* filter = i->get();
buf << " " << filter->getEntryPointFunctionName() << "(slot, color);\n";
}
buf << "} \n";
std::string bufstr;
bufstr = buf.str();
return new osg::Shader(osg::Shader::FRAGMENT, bufstr);
}
开发者ID:arucgab,项目名称:osgearth-1,代码行数:31,代码来源:ShaderFactory.cpp
示例2: VirtualProgram
void
QuadTreeTerrainEngineNode::updateTextureCombining()
{
if ( _texCompositor.valid() )
{
int numImageLayers = _update_mapf->imageLayers().size();
osg::StateSet* terrainStateSet = _terrain->getOrCreateStateSet();
if ( _texCompositor->usesShaderComposition() )
{
// Creates or updates the shader components that are generated by the texture compositor.
// These components reside in the CustomTerrain's stateset, and override the components
// installed in the VP on the engine-node's stateset in installShaders().
VirtualProgram* vp = new VirtualProgram();
terrainStateSet->setAttributeAndModes( vp, osg::StateAttribute::ON );
#if 0
VirtualProgram* vp = dynamic_cast<VirtualProgram*>( terrainStateSet->getAttribute(osg::StateAttribute::PROGRAM) );
if ( !vp )
{
// create and add it the first time around..
vp = new VirtualProgram();
terrainStateSet->setAttributeAndModes( vp, osg::StateAttribute::ON );
}
#endif
// first, update the default shader components based on the new layer count:
const ShaderFactory* sf = Registry::instance()->getShaderFactory();
vp->setShader( "osgearth_vert_setupTexturing", sf->createDefaultTextureVertexShader( numImageLayers ) );
// second, install the per-layer color filter functions.
for( int i=0; i<numImageLayers; ++i )
{
std::string layerFilterFunc = Stringify() << "osgearth_runColorFilters_" << i;
const ColorFilterChain& chain = _update_mapf->getImageLayerAt(i)->getColorFilters();
// install the wrapper function that calls all the filters in turn:
vp->setShader( layerFilterFunc, sf->createColorFilterChainFragmentShader(layerFilterFunc, chain) );
// install each of the filter entry points:
for( ColorFilterChain::const_iterator j = chain.begin(); j != chain.end(); ++j )
{
const ColorFilter* filter = j->get();
filter->install( terrainStateSet );
}
}
// not this one, because the compositor always generates a new one.
//vp->setShader( "osgearth_frag_applyTexturing", lib.createDefaultTextureFragmentShader( numImageLayers ) );
}
// next, inform the compositor that it needs to update based on a new layer count:
_texCompositor->updateMasterStateSet( terrainStateSet ); //, numImageLayers );
}
}
开发者ID:ender35,项目名称:osgearth,代码行数:57,代码来源:QuadTreeEngineNode.cpp
示例3:
bool
ColorFilterRegistry::writeChain(const ColorFilterChain& chain, Config& out_config)
{
bool wroteAtLeastOne = false;
for( ColorFilterChain::const_iterator i = chain.begin(); i != chain.end(); ++i )
{
Config conf = i->get()->getConfig();
if ( !conf.empty() )
{
out_config.add( conf );
wroteAtLeastOne = true;
}
}
return wroteAtLeastOne;
}
开发者ID:2php,项目名称:osgearth,代码行数:17,代码来源:MapNodeObserver.cpp
示例4: VirtualProgram
void
OSGTerrainEngineNode::updateTextureCombining()
{
if ( _texCompositor.valid() )
{
int numImageLayers = _update_mapf->imageLayers().size();
osg::StateSet* terrainStateSet = _terrain->getOrCreateStateSet();
if ( _texCompositor->usesShaderComposition() )
{
// Creates or updates the shader components that are generated by the texture compositor.
// These components reside in the CustomTerrain's stateset, and override the components
// installed in the VP on the engine-node's stateset in installShaders().
VirtualProgram* vp = new VirtualProgram() ;
vp->setName( "engine_osgterrain:TerrainNode" );
vp->installDefaultColoringShaders(numImageLayers);
terrainStateSet->setAttributeAndModes( vp, osg::StateAttribute::ON );
// first, update the default shader components based on the new layer count:
const ShaderFactory* sf = Registry::instance()->getShaderFactory();
// second, install the per-layer color filter functions.
for( int i=0; i<numImageLayers; ++i )
{
std::string layerFilterFunc = Stringify() << "osgearth_runColorFilters_" << i;
const ColorFilterChain& chain = _update_mapf->getImageLayerAt(i)->getColorFilters();
// install the wrapper function that calls all the filters in turn:
vp->setShader( layerFilterFunc, sf->createColorFilterChainFragmentShader(layerFilterFunc, chain) );
// install each of the filter entry points:
for( ColorFilterChain::const_iterator j = chain.begin(); j != chain.end(); ++j )
{
const ColorFilter* filter = j->get();
filter->install( terrainStateSet );
}
}
}
// next, inform the compositor that it needs to update based on a new layer count:
_texCompositor->updateMasterStateSet( terrainStateSet ); //, numImageLayers );
}
}
开发者ID:JohnDr,项目名称:osgearth,代码行数:45,代码来源:OSGTerrainEngineNode.cpp
示例5: Depth
// Generates the main shader code for rendering the terrain.
void
MPTerrainEngineNode::updateState()
{
if ( _batchUpdateInProgress )
{
_stateUpdateRequired = true;
}
else
{
if ( _elevationTextureUnit < 0 && elevationTexturesRequired() )
{
getResources()->reserveTextureImageUnit( _elevationTextureUnit, "MP Engine Elevation" );
}
osg::StateSet* terrainStateSet = getTerrainStateSet();
// required for multipass tile rendering to work
terrainStateSet->setAttributeAndModes(
new osg::Depth(osg::Depth::LEQUAL, 0, 1, true) );
// activate standard mix blending.
terrainStateSet->setAttributeAndModes(
new osg::BlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA),
osg::StateAttribute::ON );
// install shaders, if we're using them.
if ( Registry::capabilities().supportsGLSL() )
{
VirtualProgram* vp = new VirtualProgram();
vp->setName( "osgEarth.engine_mp.TerrainNode" );
terrainStateSet->setAttributeAndModes( vp, osg::StateAttribute::ON );
// bind the vertex attributes generated by the tile compiler.
vp->addBindAttribLocation( "oe_terrain_attr", osg::Drawable::ATTRIBUTE_6 );
vp->addBindAttribLocation( "oe_terrain_attr2", osg::Drawable::ATTRIBUTE_7 );
Shaders package;
package.replace( "$MP_PRIMARY_UNIT", Stringify() << _primaryUnit );
package.replace( "$MP_SECONDARY_UNIT", Stringify() << (_secondaryUnit>=0?_secondaryUnit:0) );
package.define( "MP_USE_BLENDING", (_terrainOptions.enableBlending() == true) );
package.loadFunction( vp, package.VertexModel );
package.loadFunction( vp, package.VertexView );
package.loadFunction( vp, package.Fragment );
// terrain background color; negative means use the vertex color.
Color terrainColor = _terrainOptions.color().getOrUse( Color(1,1,1,-1) );
terrainStateSet->addUniform(new osg::Uniform("oe_terrain_color", terrainColor));
// assemble color filter code snippets.
bool haveColorFilters = false;
{
// Color filter frag function:
std::string fs_colorfilters =
"#version " GLSL_VERSION_STR "\n"
GLSL_DEFAULT_PRECISION_FLOAT "\n"
"uniform int oe_layer_uid; \n"
"$COLOR_FILTER_HEAD"
"void oe_mp_apply_filters(inout vec4 color) \n"
"{ \n"
"$COLOR_FILTER_BODY"
"} \n";
std::stringstream cf_head;
std::stringstream cf_body;
const char* I = " ";
// second, install the per-layer color filter functions AND shared layer bindings.
bool ifStarted = false;
int numImageLayers = _update_mapf->imageLayers().size();
for( int i=0; i<numImageLayers; ++i )
{
ImageLayer* layer = _update_mapf->getImageLayerAt(i);
if ( layer->getEnabled() )
{
// install Color Filter function calls:
const ColorFilterChain& chain = layer->getColorFilters();
if ( chain.size() > 0 )
{
haveColorFilters = true;
if ( ifStarted ) cf_body << I << "else if ";
else cf_body << I << "if ";
cf_body << "(oe_layer_uid == " << layer->getUID() << ") {\n";
for( ColorFilterChain::const_iterator j = chain.begin(); j != chain.end(); ++j )
{
const ColorFilter* filter = j->get();
cf_head << "void " << filter->getEntryPointFunctionName() << "(inout vec4 color);\n";
cf_body << I << I << filter->getEntryPointFunctionName() << "(color);\n";
filter->install( terrainStateSet );
}
cf_body << I << "}\n";
ifStarted = true;
}
}
}
//.........这里部分代码省略.........
开发者ID:Displacer,项目名称:osgearth,代码行数:101,代码来源:MPTerrainEngineNode.cpp
示例6: Depth
//.........这里部分代码省略.........
bool haveColorFilters = false;
{
// Color filter frag function:
std::string fs_colorfilters =
"#version " GLSL_VERSION_STR "\n"
GLSL_DEFAULT_PRECISION_FLOAT "\n"
"uniform int oe_layer_uid; \n"
"$COLOR_FILTER_HEAD"
"void oe_rexEngine_applyFilters(inout vec4 color) \n"
"{ \n"
"$COLOR_FILTER_BODY"
"} \n";
std::stringstream cf_head;
std::stringstream cf_body;
const char* I = " ";
// second, install the per-layer color filter functions AND shared layer bindings.
bool ifStarted = false;
int numImageLayers = _update_mapf->imageLayers().size();
for( int i=0; i<numImageLayers; ++i )
{
ImageLayer* layer = _update_mapf->getImageLayerAt(i);
if ( layer->getEnabled() )
{
// install Color Filter function calls:
const ColorFilterChain& chain = layer->getColorFilters();
if ( chain.size() > 0 )
{
haveColorFilters = true;
if ( ifStarted ) cf_body << I << "else if ";
else cf_body << I << "if ";
cf_body << "(oe_layer_uid == " << layer->getUID() << ") {\n";
for( ColorFilterChain::const_iterator j = chain.begin(); j != chain.end(); ++j )
{
const ColorFilter* filter = j->get();
cf_head << "void " << filter->getEntryPointFunctionName() << "(inout vec4 color);\n";
cf_body << I << I << filter->getEntryPointFunctionName() << "(color);\n";
filter->install( surfaceStateSet );
}
cf_body << I << "}\n";
ifStarted = true;
}
}
}
if ( haveColorFilters )
{
std::string cf_head_str, cf_body_str;
cf_head_str = cf_head.str();
cf_body_str = cf_body.str();
replaceIn( fs_colorfilters, "$COLOR_FILTER_HEAD", cf_head_str );
replaceIn( fs_colorfilters, "$COLOR_FILTER_BODY", cf_body_str );
surfaceVP->setFunction(
"oe_rexEngine_applyFilters",
fs_colorfilters,
ShaderComp::LOCATION_FRAGMENT_COLORING,
0.0 );
}
}
// Apply uniforms for sampler bindings:
OE_DEBUG << LC << "Render Bindings:\n";
for(RenderBindings::const_iterator b = _renderBindings.begin(); b != _renderBindings.end(); ++b)
开发者ID:rmk177,项目名称:osgearth,代码行数:67,代码来源:RexTerrainEngineNode.cpp
示例7: Depth
//.........这里部分代码省略.........
GLSL_DEFAULT_PRECISION_FLOAT "\n"
"uniform int oe_layer_uid; \n"
"__COLOR_FILTER_HEAD__"
"void oe_mp_apply_filters(inout vec4 color) \n"
"{ \n"
"__COLOR_FILTER_BODY__"
"} \n";
vp->setFunction( "oe_mp_setup_coloring", vs, ShaderComp::LOCATION_VERTEX_MODEL, 0.0 );
vp->setFunction( "oe_mp_apply_coloring", fs, ShaderComp::LOCATION_FRAGMENT_COLORING, 0.0 );
// assemble color filter code snippets.
bool haveColorFilters = false;
{
std::stringstream cf_head;
std::stringstream cf_body;
const char* I = " ";
// second, install the per-layer color filter functions AND shared layer bindings.
bool ifStarted = false;
int numImageLayers = _update_mapf->imageLayers().size();
for( int i=0; i<numImageLayers; ++i )
{
ImageLayer* layer = _update_mapf->getImageLayerAt(i);
if ( layer->getEnabled() )
{
// install Color Filter function calls:
const ColorFilterChain& chain = layer->getColorFilters();
if ( chain.size() > 0 )
{
haveColorFilters = true;
if ( ifStarted ) cf_body << I << "else if ";
else cf_body << I << "if ";
cf_body << "(oe_layer_uid == " << layer->getUID() << ") {\n";
for( ColorFilterChain::const_iterator j = chain.begin(); j != chain.end(); ++j )
{
const ColorFilter* filter = j->get();
cf_head << "void " << filter->getEntryPointFunctionName() << "(inout vec4 color);\n";
cf_body << I << I << filter->getEntryPointFunctionName() << "(color);\n";
filter->install( terrainStateSet );
}
cf_body << I << "}\n";
ifStarted = true;
}
}
}
if ( haveColorFilters )
{
std::string cf_head_str, cf_body_str;
cf_head_str = cf_head.str();
cf_body_str = cf_body.str();
replaceIn( fs_colorfilters, "__COLOR_FILTER_HEAD__", cf_head_str );
replaceIn( fs_colorfilters, "__COLOR_FILTER_BODY__", cf_body_str );
vp->setFunction( "oe_mp_apply_filters", fs_colorfilters, ShaderComp::LOCATION_FRAGMENT_COLORING, 0.0 );
}
}
// binding for the terrain texture
terrainStateSet->getOrCreateUniform(
"oe_layer_tex", osg::Uniform::SAMPLER_2D )->set( _primaryUnit );
// binding for the secondary texture (for LOD blending)
terrainStateSet->getOrCreateUniform(
"oe_layer_tex_parent", osg::Uniform::SAMPLER_2D )->set( _secondaryUnit );
// binding for the default secondary texture matrix
osg::Matrixf parent_mat;
parent_mat(0,0) = 0.0f;
terrainStateSet->getOrCreateUniform(
"oe_layer_parent_matrix", osg::Uniform::FLOAT_MAT4 )->set( parent_mat );
// uniform that controls per-layer opacity
terrainStateSet->getOrCreateUniform(
"oe_layer_opacity", osg::Uniform::FLOAT )->set( 1.0f );
// uniform that conveys the layer UID to the shaders; necessary
// for per-layer branching (like color filters)
// UID -1 => no image layer (no texture)
terrainStateSet->getOrCreateUniform(
"oe_layer_uid", osg::Uniform::INT )->set( -1 );
// uniform that conveys the render order, since the shaders
// need to know which is the first layer in order to blend properly
terrainStateSet->getOrCreateUniform(
"oe_layer_order", osg::Uniform::INT )->set( 0 );
// base terrain color.
if ( useTerrainColor )
{
terrainStateSet->getOrCreateUniform(
"oe_terrain_color", osg::Uniform::FLOAT_VEC4 )->set( *_terrainOptions.color() );
}
}
_stateUpdateRequired = false;
}
}
开发者ID:aurelien35,项目名称:osgearth,代码行数:101,代码来源:MPTerrainEngineNode.cpp
注:本文中的colorfilterchain::const_iterator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论