本文整理汇总了C++中ImageLayer::shareTexMatUniformName方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageLayer::shareTexMatUniformName方法的具体用法?C++ ImageLayer::shareTexMatUniformName怎么用?C++ ImageLayer::shareTexMatUniformName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageLayer
的用法示例。
在下文中一共展示了ImageLayer::shareTexMatUniformName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
RexTerrainEngineNode::addTileLayer(Layer* tileLayer)
{
if ( tileLayer && tileLayer->getEnabled() )
{
// Install the image layer stateset on this layer.
// Later we will refactor this into an ImageLayerRenderer or something similar.
//osg::StateSet* stateSet = tileLayer->getOrCreateStateSet();
//stateSet->merge(*getSurfaceStateSet());
ImageLayer* imageLayer = dynamic_cast<ImageLayer*>(tileLayer);
if (imageLayer)
{
// for a shared layer, allocate a shared image unit if necessary.
if ( imageLayer->isShared() )
{
optional<int>& unit = imageLayer->shareImageUnit();
if ( !unit.isSet() )
{
int temp;
if ( getResources()->reserveTextureImageUnit(temp) )
{
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 ( unit.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() = unit.get();
newBinding.samplerName() = imageLayer->shareTexUniformName().get();
newBinding.matrixName() = imageLayer->shareTexMatUniformName().get();
OE_INFO << LC
<< " .. Sampler=\"" << newBinding.samplerName() << "\", "
<< "Matrix=\"" << newBinding.matrixName() << ", "
<< "unit=" << newBinding.unit() << "\n";
}
}
}
else
{
// non-image tile layer. Keep track of these..
}
refresh();
}
}
示例2: updateModels
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);
}
}
}