本文整理汇总了C++中ProgramObject::activate方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramObject::activate方法的具体用法?C++ ProgramObject::activate怎么用?C++ ProgramObject::activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgramObject
的用法示例。
在下文中一共展示了ProgramObject::activate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getActivatedProgramWithTileData
ProgramObject* ChunkRenderer::getActivatedProgramWithTileData(
LayeredTextureShaderProvider* layeredTextureShaderProvider,
std::shared_ptr<LayeredTextureShaderUniformIdHandler> programUniformHandler,
const Chunk& chunk)
{
const ChunkIndex& chunkIndex = chunk.index();
std::array<std::vector<std::shared_ptr<TileProvider> >,
LayeredTextures::NUM_TEXTURE_CATEGORIES> tileProviders;
LayeredTexturePreprocessingData layeredTexturePreprocessingData;
for (size_t category = 0; category < LayeredTextures::NUM_TEXTURE_CATEGORIES; category++) {
tileProviders[category] = _tileProviderManager->getTileProviderGroup(category).getActiveTileProviders();
LayeredTextureInfo layeredTextureInfo;
layeredTextureInfo.lastLayerIdx = tileProviders[category].size() - 1;
layeredTextureInfo.layerBlendingEnabled = _tileProviderManager->getTileProviderGroup(category).levelBlendingEnabled;
layeredTexturePreprocessingData.layeredTextureInfo[category] = layeredTextureInfo;
}
layeredTexturePreprocessingData.keyValuePairs.push_back(
std::pair<std::string, std::string>(
"useAtmosphere",
std::to_string(chunk.owner()->atmosphereEnabled)));
layeredTexturePreprocessingData.keyValuePairs.push_back(
std::pair<std::string, std::string>(
"showChunkEdges",
std::to_string(chunk.owner()->debugOptions.showChunkEdges)));
layeredTexturePreprocessingData.keyValuePairs.push_back(
std::pair<std::string, std::string>(
"showHeightResolution",
std::to_string(chunk.owner()->debugOptions.showHeightResolution)));
layeredTexturePreprocessingData.keyValuePairs.push_back(
std::pair<std::string, std::string>(
"showHeightIntensities",
std::to_string(chunk.owner()->debugOptions.showHeightIntensities)));
layeredTexturePreprocessingData.keyValuePairs.push_back(
std::pair<std::string, std::string>(
"defaultHeight",
std::to_string(Chunk::DEFAULT_HEIGHT)));
// Now the shader program can be accessed
ProgramObject* programObject =
layeredTextureShaderProvider->getUpdatedShaderProgram(
layeredTexturePreprocessingData);
programUniformHandler->updateIdsIfNecessary(layeredTextureShaderProvider);
// Activate the shader program
programObject->activate();
// Initialize all texture units
struct BlendTexUnits {
ghoul::opengl::TextureUnit blendTexture0;
ghoul::opengl::TextureUnit blendTexture1;
ghoul::opengl::TextureUnit blendTexture2;
};
std::array<std::vector<BlendTexUnits>, LayeredTextures::NUM_TEXTURE_CATEGORIES> texUnits;
for (size_t category = 0; category < LayeredTextures::NUM_TEXTURE_CATEGORIES; category++) {
texUnits[category].resize(tileProviders[category].size());
}
// Go through all the categories
for (size_t category = 0; category < LayeredTextures::NUM_TEXTURE_CATEGORIES; category++) {
// Go through all the providers in this category
int i = 0;
for (auto it = tileProviders[category].begin(); it != tileProviders[category].end(); it++) {
auto tileProvider = it->get();
// Get the texture that should be used for rendering
TileAndTransform tileAndTransform = TileSelector::getHighestResolutionTile(tileProvider, chunkIndex);
if (tileAndTransform.tile.status == Tile::Status::Unavailable) {
tileAndTransform.tile = tileProvider->getDefaultTile();
tileAndTransform.uvTransform.uvOffset = { 0, 0 };
tileAndTransform.uvTransform.uvScale = { 1, 1 };
}
activateTileAndSetTileUniforms(
programUniformHandler,
LayeredTextures::TextureCategory(category),
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::none,
i,
texUnits[category][i].blendTexture0,
tileAndTransform);
// If blending is enabled, two more textures are needed
if (layeredTexturePreprocessingData.layeredTextureInfo[category].layerBlendingEnabled) {
TileAndTransform tileAndTransformParent1 = TileSelector::getHighestResolutionTile(tileProvider, chunkIndex, 1);
if (tileAndTransformParent1.tile.status == Tile::Status::Unavailable) {
tileAndTransformParent1 = tileAndTransform;
}
//.........这里部分代码省略.........