本文整理汇总了C++中ImageLayer类的典型用法代码示例。如果您正苦于以下问题:C++ ImageLayer类的具体用法?C++ ImageLayer怎么用?C++ ImageLayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageLayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
RexTerrainEngineNode::addTileLayer(Layer* tileLayer)
{
if ( tileLayer && tileLayer->getEnabled() )
{
ImageLayer* imageLayer = dynamic_cast<ImageLayer*>(tileLayer);
if (imageLayer)
{
// for a shared layer, allocate a shared image unit if necessary.
if ( imageLayer->isShared() )
{
if (!imageLayer->shareImageUnit().isSet())
{
int temp;
if ( getResources()->reserveTextureImageUnit(temp, imageLayer->getName().c_str()) )
{
imageLayer->shareImageUnit() = temp;
//OE_INFO << LC << "Image unit " << temp << " assigned to shared layer " << imageLayer->getName() << std::endl;
}
else
{
OE_WARN << LC << "Insufficient GPU image units to share layer " << imageLayer->getName() << std::endl;
}
}
// Build a sampler binding for the shared layer.
if ( imageLayer->shareImageUnit().isSet() )
{
// Find the next empty SHARED slot:
unsigned newIndex = SamplerBinding::SHARED;
while (_renderBindings[newIndex].isActive())
++newIndex;
// Put the new binding there:
SamplerBinding& newBinding = _renderBindings[newIndex];
newBinding.usage() = SamplerBinding::SHARED;
newBinding.sourceUID() = imageLayer->getUID();
newBinding.unit() = imageLayer->shareImageUnit().get();
newBinding.samplerName() = imageLayer->shareTexUniformName().get();
newBinding.matrixName() = imageLayer->shareTexMatUniformName().get();
OE_INFO << LC
<< "Shared Layer \"" << imageLayer->getName() << "\" : sampler=\"" << newBinding.samplerName() << "\", "
<< "matrix=\"" << newBinding.matrixName() << "\", "
<< "unit=" << newBinding.unit() << "\n";
}
}
}
else
{
// non-image tile layer. Keep track of these..
}
if (_terrain)
{
// Update the existing render models, and trigger a data reload.
// Later we can limit the reload to an update of only the new data.
UpdateRenderModels updateModels(_mapFrame);
#if 0
// This uses the loaddata filter approach which will only request
// data for one layer. It mostly works but not 100%; see hires-insets
// as an example. Removing the world layer and re-adding it while
// zoomed in doesn't result in all tiles reloading. Possibly a
// synchronization issue.
ImageLayerVector imageLayers;
_mapFrame.getLayers(imageLayers);
if (imageLayers.size() == 1)
updateModels.setReloadData(true);
else
updateModels.layersToLoad().insert(tileLayer->getUID());
#else
updateModels.setReloadData(true);
#endif
_terrain->accept(updateModels);
}
}
}
示例2: mapConf
Config
EarthFileSerializer2::serialize(const MapNode* input, const std::string& referrer) const
{
Config mapConf("map");
mapConf.set("version", "2");
if ( !input || !input->getMap() )
return mapConf;
const Map* map = input->getMap();
MapFrame mapf( map, Map::ENTIRE_MODEL );
// the map and node options:
Config optionsConf = map->getInitialMapOptions().getConfig();
optionsConf.merge( input->getMapNodeOptions().getConfig() );
mapConf.add( "options", optionsConf );
// the layers
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getImageLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "image", layerConf );
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); ++i )
{
ElevationLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getElevationLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "elevation", layerConf );
}
for( ModelLayerVector::const_iterator i = mapf.modelLayers().begin(); i != mapf.modelLayers().end(); ++i )
{
ModelLayer* layer = i->get();
Config layerConf = layer->getModelLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getModelLayerOptions().driver()->getDriver());
mapConf.add( "model", layerConf );
}
Config ext = input->externalConfig();
if ( !ext.empty() )
{
ext.key() = "extensions";
mapConf.add( ext );
}
#if 0 // removed until it can be debugged.
// Re-write pathnames in the Config so they are relative to the new referrer.
if ( _rewritePaths && !referrer.empty() )
{
RewritePaths rewritePaths( referrer );
rewritePaths.setRewriteAbsolutePaths( _rewriteAbsolutePaths );
rewritePaths.apply( mapConf );
}
#endif
return mapConf;
}
示例3: getSurfaceStateSet
//.........这里部分代码省略.........
{
package.load(surfaceVP, package.MORPHING_VERT);
if (_terrainOptions.morphImagery() == true)
{
surfaceStateSet->setDefine("OE_TERRAIN_MORPH_IMAGERY");
}
if (_terrainOptions.morphTerrain() == true)
{
surfaceStateSet->setDefine("OE_TERRAIN_MORPH_GEOMETRY");
}
}
// 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_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;
ImageLayerVector imageLayers;
_update_mapf->getLayers(imageLayers);
for( int i=0; i<imageLayers.size(); ++i )
{
ImageLayer* layer = imageLayers.at(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();
示例4: if
//.........这里部分代码省略.........
}
// Read the orientation
std::string orientationStr = mapElem->Attribute("orientation");
if (!orientationStr.compare("orthogonal"))
{
orientation = TMX_MO_ORTHOGONAL;
}
else if (!orientationStr.compare("isometric"))
{
orientation = TMX_MO_ISOMETRIC;
}
else if (!orientationStr.compare("staggered"))
{
orientation = TMX_MO_STAGGERED;
}
// Read the render order
if (mapElem->Attribute("renderorder"))
{
std::string renderorderStr = mapElem->Attribute("renderorder");
if (!renderorderStr.compare("right-down"))
{
render_order = TMX_RIGHT_DOWN;
}
else if (!renderorderStr.compare("right-up"))
{
render_order = TMX_RIGHT_UP;
}
else if (!renderorderStr.compare("left-down"))
{
render_order = TMX_LEFT_DOWN;
}
else if (!renderorderStr.compare("left-down"))
{
render_order = TMX_LEFT_UP;
}
}
const tinyxml2::XMLNode *node = mapElem->FirstChild();
while( node )
{
// Read the map properties.
if( strcmp( node->Value(), "properties" ) == 0 )
{
properties.Parse(node);
}
// Iterate through all of the tileset elements.
if( strcmp( node->Value(), "tileset" ) == 0 )
{
// Allocate a new tileset and parse it.
Tileset *tileset = new Tileset();
tileset->Parse(node->ToElement());
// Add the tileset to the list.
tilesets.push_back(tileset);
}
// Iterate through all of the "layer" (tile layer) elements.
if( strcmp( node->Value(), "layer" ) == 0 )
{
// Allocate a new tile layer and parse it.
TileLayer *tileLayer = new TileLayer(this);
tileLayer->Parse(node);
// Add the tile layer to the lists.
tile_layers.push_back(tileLayer);
layers.push_back(tileLayer);
}
// Iterate through all of the "imagelayer" (image layer) elements.
if( strcmp( node->Value(), "imagelayer" ) == 0 )
{
// Allocate a new image layer and parse it.
ImageLayer *imageLayer = new ImageLayer(this);
imageLayer->Parse(node);
// Add the image layer to the lists.
image_layers.push_back(imageLayer);
layers.push_back(imageLayer);
}
// Iterate through all of the "objectgroup" (object layer) elements.
if( strcmp( node->Value(), "objectgroup" ) == 0 )
{
// Allocate a new object group and parse it.
ObjectGroup *objectGroup = new ObjectGroup(this);
objectGroup->Parse(node);
// Add the object group to the lists.
object_groups.push_back(objectGroup);
layers.push_back(objectGroup);
}
node = node->NextSibling();
}
}
示例5: VirtualProgram
//.........这里部分代码省略.........
" }\n"
<< (useBlending ?
" if ( oe_layer_order == 0 ) { \n"
" color = texel*texel.a + color*(1.0-texel.a); \n" // simulate src_alpha, 1-src_alpha blens
" } \n"
" else \n" : ""
) <<
" color = texel; \n"
"} \n";
// 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";
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();
示例6: VirtualProgram
//.........这里部分代码省略.........
"{ \n"
"__COLOR_FILTER_BODY__"
"} \n";
// install the gl_MultiTexCoord* variable that uses the proper texture
// image unit:
replaceIn( vs, "__GL_MULTITEXCOORD1__", Stringify() << "gl_MultiTexCoord" << _primaryUnit );
replaceIn( vs, "__GL_MULTITEXCOORD2__", Stringify() << "gl_MultiTexCoord" << _secondaryUnit );
vp->setFunction( "oe_mp_setup_coloring", vs, ShaderComp::LOCATION_VERTEX_MODEL, 0.0 );
if ( _terrainOptions.premultipliedAlpha() == true )
vp->setFunction( "oe_mp_apply_coloring_pma", fs_pma, ShaderComp::LOCATION_FRAGMENT_COLORING, 0.0 );
else
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 = " ";
if ( _terrainOptions.premultipliedAlpha() == true )
{
// un-PMA the color before passing it to the color filters.
cf_body << I << "if (color.a > 0.0) color.rgb /= color.a; \n";
}
// 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 ( _terrainOptions.premultipliedAlpha() == true )
{
// re-PMA the color after it passes through the color filters.
cf_body << I << "color.rgb *= color.a; \n";
}
示例7: SRS
void
Map::calculateProfile()
{
if ( !_profile.valid() )
{
osg::ref_ptr<const Profile> userProfile;
if ( _mapOptions.profile().isSet() )
{
userProfile = Profile::create( _mapOptions.profile().value() );
}
if ( _mapOptions.coordSysType() == MapOptions::CSTYPE_GEOCENTRIC )
{
if ( userProfile.valid() )
{
if ( userProfile->isOK() && userProfile->getSRS()->isGeographic() )
{
_profile = userProfile.get();
}
else
{
OE_WARN << LC
<< "Map is geocentric, but the configured profile SRS ("
<< userProfile->getSRS()->getName() << ") is not geographic; "
<< "it will be ignored."
<< std::endl;
}
}
}
else if ( _mapOptions.coordSysType() == MapOptions::CSTYPE_GEOCENTRIC_CUBE )
{
if ( userProfile.valid() )
{
if ( userProfile->isOK() && userProfile->getSRS()->isCube() )
{
_profile = userProfile.get();
}
else
{
OE_WARN << LC
<< "Map is geocentric cube, but the configured profile SRS ("
<< userProfile->getSRS()->getName() << ") is not geocentric cube; "
<< "it will be ignored."
<< std::endl;
}
}
}
else // CSTYPE_PROJECTED
{
if ( userProfile.valid() )
{
if ( userProfile->isOK() && userProfile->getSRS()->isProjected() )
{
_profile = userProfile.get();
}
else
{
OE_WARN << LC
<< "Map is projected, but the configured profile SRS ("
<< userProfile->getSRS()->getName() << ") is not projected; "
<< "it will be ignored."
<< std::endl;
}
}
}
// At this point, if we don't have a profile we need to search tile sources until we find one.
if ( !_profile.valid() )
{
Threading::ScopedReadLock lock( _mapDataMutex );
for( ImageLayerVector::iterator i = _imageLayers.begin(); i != _imageLayers.end() && !_profile.valid(); i++ )
{
ImageLayer* layer = i->get();
if ( layer->getTileSource() )
{
_profile = layer->getTileSource()->getProfile();
}
}
for( ElevationLayerVector::iterator i = _elevationLayers.begin(); i != _elevationLayers.end() && !_profile.valid(); i++ )
{
ElevationLayer* layer = i->get();
if ( layer->getTileSource() )
{
_profile = layer->getTileSource()->getProfile();
}
}
}
// ensure that the profile we found is the correct kind
// convert a geographic profile to Plate Carre if necessary
if ( _mapOptions.coordSysType() == MapOptions::CSTYPE_GEOCENTRIC && !( _profile.valid() && _profile->getSRS()->isGeographic() ) )
{
// by default, set a geocentric map to use global-geodetic WGS84.
_profile = osgEarth::Registry::instance()->getGlobalGeodeticProfile();
}
else if ( _mapOptions.coordSysType() == MapOptions::CSTYPE_GEOCENTRIC_CUBE && !( _profile.valid() && _profile->getSRS()->isCube() ) )
{
//If the map type is a Geocentric Cube, set the profile to the cube profile.
//.........这里部分代码省略.........
示例8: getResources
// 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();
if ( !terrainStateSet )
return;
// 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 );
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.load( vp, package.EngineVertexModel );
package.load( vp, package.EngineVertexView );
package.load( vp, package.EngineFragment );
if ( this->normalTexturesRequired() )
{
package.load( vp, package.NormalMapVertex );
package.load( vp, package.NormalMapFragment );
terrainStateSet->addUniform( new osg::Uniform("oe_tile_normalTex", _normalMapUnit) );
}
// 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));
if ( _update_mapf )
{
// 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.
ImageLayerVector imageLayers;
_update_mapf->getLayers(imageLayers);
bool ifStarted = false;
int numImageLayers = imageLayers.size();
for( int i=0; i<numImageLayers; ++i )
{
ImageLayer* layer = imageLayers[i].get();
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();
//.........这里部分代码省略.........
示例9: if
void
Map::calculateProfile()
{
if ( !_profile.valid() )
{
osg::ref_ptr<const Profile> userProfile;
if ( _mapOptions.profile().isSet() )
{
userProfile = Profile::create( _mapOptions.profile().value() );
}
if ( _mapOptions.coordSysType() == MapOptions::CSTYPE_GEOCENTRIC )
{
if ( userProfile.valid() )
{
if ( userProfile->isOK() && userProfile->getSRS()->isGeographic() )
{
_profile = userProfile.get();
}
else
{
OE_WARN << LC
<< "Map is geocentric, but the configured profile does not "
<< "have a geographic SRS. Falling back on default.."
<< std::endl;
}
}
if ( !_profile.valid() )
{
// by default, set a geocentric map to use global-geodetic WGS84.
_profile = osgEarth::Registry::instance()->getGlobalGeodeticProfile();
}
}
else if ( _mapOptions.coordSysType() == MapOptions::CSTYPE_GEOCENTRIC_CUBE )
{
//If the map type is a Geocentric Cube, set the profile to the cube profile.
_profile = osgEarth::Registry::instance()->getCubeProfile();
}
else // CSTYPE_PROJECTED
{
if ( userProfile.valid() )
{
_profile = userProfile.get();
}
}
// At this point, if we don't have a profile we need to search tile sources until we find one.
if ( !_profile.valid() )
{
Threading::ScopedReadLock lock( _mapDataMutex );
for( ImageLayerVector::iterator i = _imageLayers.begin(); i != _imageLayers.end() && !_profile.valid(); i++ )
{
ImageLayer* layer = i->get();
if ( layer->getTileSource() )
{
_profile = layer->getTileSource()->getProfile();
}
}
for( ElevationLayerVector::iterator i = _elevationLayers.begin(); i != _elevationLayers.end() && !_profile.valid(); i++ )
{
ElevationLayer* layer = i->get();
if ( layer->getTileSource() )
{
_profile = layer->getTileSource()->getProfile();
}
}
}
// finally, fire an event if the profile has been set.
if ( _profile.valid() )
{
OE_INFO << LC << "Map profile is: " << _profile->toString() << std::endl;
for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
{
i->get()->onMapInfoEstablished( MapInfo(this) );
}
}
else
{
OE_WARN << LC << "Warning, not yet able to establish a map profile!" << std::endl;
}
}
if ( _profile.valid() )
{
// tell all the loaded layers what the profile is, as a hint
{
Threading::ScopedWriteLock lock( _mapDataMutex );
for( ImageLayerVector::iterator i = _imageLayers.begin(); i != _imageLayers.end(); i++ )
{
ImageLayer* layer = i->get();
layer->setTargetProfileHint( _profile.get() );
//.........这里部分代码省略.........
示例10: getSurfaceStateSet
//.........这里部分代码省略.........
// uniform that communicates the availability of multisampling.
landCoverStateSet->addUniform( new osg::Uniform(
"oe_terrain_hasMultiSamples",
osg::DisplaySettings::instance()->getMultiSamples()) );
landCoverStateSet->setAttributeAndModes(
new osg::BlendFunc(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO),
osg::StateAttribute::OVERRIDE );
landCoverStateSet->setAttributeAndModes( new osg::PatchParameter(3) );
}
// 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_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();
示例11: if
void Map::ParseText(const string &text)
{
// Create a tiny xml document and use it to parse the text.
TiXmlDocument doc;
doc.Parse(text.c_str());
// Check for parsing errors.
if (doc.Error())
{
has_error = true;
error_code = TMX_PARSING_ERROR;
error_text = doc.ErrorDesc();
return;
}
TiXmlNode *mapNode = doc.FirstChild("map");
TiXmlElement* mapElem = mapNode->ToElement();
// Read the map attributes.
mapElem->Attribute("version", &version);
mapElem->Attribute("width", &width);
mapElem->Attribute("height", &height);
mapElem->Attribute("tilewidth", &tile_width);
mapElem->Attribute("tileheight", &tile_height);
// Read the orientation
std::string orientationStr = mapElem->Attribute("orientation");
if (!orientationStr.compare("orthogonal"))
{
orientation = TMX_MO_ORTHOGONAL;
}
else if (!orientationStr.compare("isometric"))
{
orientation = TMX_MO_ISOMETRIC;
}
else if (!orientationStr.compare("staggered"))
{
orientation = TMX_MO_STAGGERED;
}
const TiXmlNode *node = mapElem->FirstChild();
int zOrder = 0;
while( node )
{
// Read the map properties.
if( strcmp( node->Value(), "properties" ) == 0 )
{
properties.Parse(node);
}
// Iterate through all of the tileset elements.
if( strcmp( node->Value(), "tileset" ) == 0 )
{
// Allocate a new tileset and parse it.
Tileset *tileset = new Tileset();
tileset->Parse(node->ToElement());
// Add the tileset to the list.
tilesets.push_back(tileset);
}
// Iterate through all of the layer elements.
if( strcmp( node->Value(), "layer" ) == 0 )
{
// Allocate a new layer and parse it.
Layer *layer = new Layer(this);
layer->Parse(node);
layer->SetZOrder( zOrder );
++zOrder;
// Add the layer to the list.
layers.push_back(layer);
}
// Iterate through all of the imagen layer elements.
if( strcmp( node->Value(), "imagelayer" ) == 0 )
{
// Allocate a new layer and parse it.
ImageLayer *imageLayer = new ImageLayer(this);
imageLayer->Parse(node);
imageLayer->SetZOrder( zOrder );
++zOrder;
// Add the layer to the list.
image_layers.push_back(imageLayer);
}
// Iterate through all of the objectgroup elements.
if( strcmp( node->Value(), "objectgroup" ) == 0 )
{
// Allocate a new object group and parse it.
ObjectGroup *objectGroup = new ObjectGroup();
objectGroup->Parse(node);
objectGroup->SetZOrder( zOrder );
++zOrder;
// Add the object group to the list.
object_groups.push_back(objectGroup);
//.........这里部分代码省略.........
示例12: cols
dimension_t cols(const ImageLayer& img) { return img.num_cols(); }
示例13: rows
dimension_t rows(const ImageLayer& img) { return img.num_rows(); }
示例14: MOZ_LAYERS_LOG
bool
LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
const TargetConfig& targetConfig,
const bool& isFirstPaint,
InfallibleTArray<EditReply>* reply)
{
#ifdef COMPOSITOR_PERFORMANCE_WARNING
TimeStamp updateStart = TimeStamp::Now();
#endif
MOZ_LAYERS_LOG(("[ParentSide] received txn with %d edits", cset.Length()));
if (mDestroyed || !layer_manager() || layer_manager()->IsDestroyed()) {
return true;
}
EditReplyVector replyv;
layer_manager()->BeginTransactionWithTarget(NULL);
for (EditArray::index_type i = 0; i < cset.Length(); ++i) {
const Edit& edit = cset[i];
switch (edit.type()) {
// Create* ops
case Edit::TOpCreateThebesLayer: {
MOZ_LAYERS_LOG(("[ParentSide] CreateThebesLayer"));
nsRefPtr<ThebesLayerComposite> layer =
layer_manager()->CreateThebesLayerComposite();
AsLayerComposite(edit.get_OpCreateThebesLayer())->Bind(layer);
break;
}
case Edit::TOpCreateContainerLayer: {
MOZ_LAYERS_LOG(("[ParentSide] CreateContainerLayer"));
nsRefPtr<ContainerLayer> layer = layer_manager()->CreateContainerLayerComposite();
AsLayerComposite(edit.get_OpCreateContainerLayer())->Bind(layer);
break;
}
case Edit::TOpCreateImageLayer: {
MOZ_LAYERS_LOG(("[ParentSide] CreateImageLayer"));
nsRefPtr<ImageLayerComposite> layer =
layer_manager()->CreateImageLayerComposite();
AsLayerComposite(edit.get_OpCreateImageLayer())->Bind(layer);
break;
}
case Edit::TOpCreateColorLayer: {
MOZ_LAYERS_LOG(("[ParentSide] CreateColorLayer"));
nsRefPtr<ColorLayerComposite> layer = layer_manager()->CreateColorLayerComposite();
AsLayerComposite(edit.get_OpCreateColorLayer())->Bind(layer);
break;
}
case Edit::TOpCreateCanvasLayer: {
MOZ_LAYERS_LOG(("[ParentSide] CreateCanvasLayer"));
nsRefPtr<CanvasLayerComposite> layer =
layer_manager()->CreateCanvasLayerComposite();
AsLayerComposite(edit.get_OpCreateCanvasLayer())->Bind(layer);
break;
}
case Edit::TOpCreateRefLayer: {
MOZ_LAYERS_LOG(("[ParentSide] CreateRefLayer"));
nsRefPtr<RefLayerComposite> layer =
layer_manager()->CreateRefLayerComposite();
AsLayerComposite(edit.get_OpCreateRefLayer())->Bind(layer);
break;
}
// Attributes
case Edit::TOpSetLayerAttributes: {
MOZ_LAYERS_LOG(("[ParentSide] SetLayerAttributes"));
const OpSetLayerAttributes& osla = edit.get_OpSetLayerAttributes();
Layer* layer = AsLayerComposite(osla)->AsLayer();
const LayerAttributes& attrs = osla.attrs();
const CommonLayerAttributes& common = attrs.common();
layer->SetVisibleRegion(common.visibleRegion());
layer->SetContentFlags(common.contentFlags());
layer->SetOpacity(common.opacity());
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL);
layer->SetBaseTransform(common.transform().value());
layer->SetPostScale(common.postXScale(), common.postYScale());
layer->SetIsFixedPosition(common.isFixedPosition());
layer->SetFixedPositionAnchor(common.fixedPositionAnchor());
layer->SetFixedPositionMargins(common.fixedPositionMargin());
if (PLayerParent* maskLayer = common.maskLayerParent()) {
layer->SetMaskLayer(cast(maskLayer)->AsLayer());
} else {
layer->SetMaskLayer(NULL);
}
layer->SetAnimations(common.animations());
typedef SpecificLayerAttributes Specific;
const SpecificLayerAttributes& specific = attrs.specific();
switch (specific.type()) {
//.........这里部分代码省略.........
示例15: mapf
void
TileBuilder::createTile(const TileKey& key,
bool parallelize,
osg::ref_ptr<Tile>& out_tile,
bool& out_hasRealData,
bool& out_hasLodBlendedLayers )
{
MapFrame mapf( _map, Map::MASKED_TERRAIN_LAYERS );
SourceRepo repo;
// init this to false, then search for real data. "Real data" is data corresponding
// directly to the key, as opposed to fallback data, which is derived from a lower
// LOD key.
out_hasRealData = false;
out_hasLodBlendedLayers = false;
const MapInfo& mapInfo = mapf.getMapInfo();
// If we need more than one layer, fetch them in parallel.
// TODO: change the test based on isKeyValid total.
if ( parallelize && (mapf.imageLayers().size() + mapf.elevationLayers().size() > 1) )
{
// count the valid layers.
int jobCount = 0;
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
if ( i->get()->isKeyValid( key ) )
++jobCount;
if ( i->get()->getImageLayerOptions().lodBlending() == true )
out_hasLodBlendedLayers = true;
}
if ( mapf.elevationLayers().size() > 0 )
++jobCount;
// A thread job monitoring event:
Threading::MultiEvent semaphore( jobCount );
// Start the image layer jobs:
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
if ( layer->isKeyValid(key) )
{
ParallelTask<BuildColorLayer>* j = new ParallelTask<BuildColorLayer>( &semaphore );
j->init( key, layer, mapInfo, _terrainOptions, repo );
j->setPriority( -(float)key.getLevelOfDetail() );
_service->add( j );
}
}
// If we have elevation layers, start an elevation job as well. Otherwise just create an
// empty one while we're waiting for the images to load.
if ( mapf.elevationLayers().size() > 0 )
{
ParallelTask<BuildElevLayer>* ej = new ParallelTask<BuildElevLayer>( &semaphore );
ej->init( key, mapf, _terrainOptions, repo );
ej->setPriority( -(float)key.getLevelOfDetail() );
_service->add( ej );
}
else
{
BuildElevLayer build;
build.init( key, mapf, _terrainOptions, repo );
build.execute();
}
// Wait for all the jobs to finish.
semaphore.wait();
}
// Fetch the image data serially:
else
{
// gather all the image layers serially.
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
if ( layer->isKeyValid(key) )
{
BuildColorLayer build;
build.init( key, layer, mapInfo, _terrainOptions, repo );
build.execute();
}
if ( layer->getImageLayerOptions().lodBlending() == true )
out_hasLodBlendedLayers = true;
}
// make an elevation layer.
BuildElevLayer build;
build.init( key, mapf, _terrainOptions, repo );
build.execute();
}
// Bail out now if there's no data to be had.
if ( repo._colorLayers.size() == 0 && !repo._elevLayer.getHFLayer() )
//.........这里部分代码省略.........