mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Add GPULayerManager and remove LayeredTextureShaderUniformIdHandler
This commit is contained in:
@@ -192,5 +192,39 @@ namespace globebrowsing {
|
||||
}
|
||||
|
||||
|
||||
// LayerManager
|
||||
|
||||
void GPULayerManager::setValue(ProgramObject* programObject, const LayerManager& layerManager, const TileIndex& tileIndex){
|
||||
auto layerGroups = layerManager.layerGroups();
|
||||
for (size_t i = 0; i < layerGroups.size(); ++i){
|
||||
std::string nameBase = LayeredTextures::TEXTURE_CATEGORY_NAMES[i];
|
||||
gpuLayerGroups[i]->setValue(programObject, *layerGroups[i], tileIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void GPULayerManager::updateUniformLocations(ProgramObject* programObject, const LayerManager& layerManager){
|
||||
auto layerGroups = layerManager.layerGroups();
|
||||
if(gpuLayerGroups.size() != layerGroups.size()){
|
||||
gpuLayerGroups.resize(layerGroups.size());
|
||||
for(auto& gpuLayerGroup : gpuLayerGroups){
|
||||
gpuLayerGroup = std::make_unique<GPULayerGroup>();
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < layerGroups.size(); ++i){
|
||||
std::string nameBase = LayeredTextures::TEXTURE_CATEGORY_NAMES[i];
|
||||
gpuLayerGroups[i]->updateUniformLocations(programObject, *layerGroups[i], nameBase, i);
|
||||
}
|
||||
}
|
||||
|
||||
void GPULayerManager::deactivate(){
|
||||
for (size_t i = 0; i < gpuLayerGroups.size(); ++i){
|
||||
gpuLayerGroups[i]->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
@@ -147,6 +147,17 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class LayerManager;
|
||||
class GPULayerManager{
|
||||
public:
|
||||
|
||||
virtual void setValue(ProgramObject* programObject, const LayerManager& layerManager, const TileIndex& tileIndex);
|
||||
virtual void updateUniformLocations(ProgramObject* programObject, const LayerManager& layerManager);
|
||||
virtual void deactivate();
|
||||
private:
|
||||
std::vector<std::unique_ptr<GPULayerGroup>> gpuLayerGroups;
|
||||
};
|
||||
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
@@ -158,10 +158,10 @@ namespace globebrowsing {
|
||||
initData.preprocessTiles = i == LayeredTextures::HeightMaps;
|
||||
std::string groupName = LayeredTextures::TEXTURE_CATEGORY_NAMES[i];
|
||||
|
||||
layerGroups.push_back(std::make_shared<LayerGroup>(groupName, texturesDict));
|
||||
_layerGroups.push_back(std::make_shared<LayerGroup>(groupName, texturesDict));
|
||||
}
|
||||
|
||||
for(auto layerGroup : layerGroups){
|
||||
for(auto layerGroup : _layerGroups){
|
||||
addPropertySubOwner(layerGroup.get());
|
||||
}
|
||||
}
|
||||
@@ -171,21 +171,26 @@ namespace globebrowsing {
|
||||
}
|
||||
|
||||
LayerGroup& LayerManager::layerGroup(size_t groupId) {
|
||||
return *layerGroups[groupId];
|
||||
return *_layerGroups[groupId];
|
||||
}
|
||||
|
||||
LayerGroup& LayerManager::layerGroup(LayeredTextures::TextureCategory category) {
|
||||
return *layerGroups[category];
|
||||
return *_layerGroups[category];
|
||||
}
|
||||
|
||||
const std::vector<std::shared_ptr<LayerGroup>>& LayerManager::layerGroups() const {
|
||||
return _layerGroups;
|
||||
}
|
||||
|
||||
|
||||
void LayerManager::update() {
|
||||
for (auto& layerGroup : layerGroups) {
|
||||
for (auto& layerGroup : _layerGroups) {
|
||||
layerGroup->update();
|
||||
}
|
||||
}
|
||||
|
||||
void LayerManager::reset(bool includeDisabled) {
|
||||
for (auto& layerGroup : layerGroups) {
|
||||
for (auto& layerGroup : _layerGroups) {
|
||||
for (auto layer : layerGroup->layers) {
|
||||
if (layer->enabled() || includeDisabled) {
|
||||
layer->tileProvider()->reset();
|
||||
|
||||
@@ -111,12 +111,14 @@ namespace globebrowsing {
|
||||
LayerGroup& layerGroup(size_t groupId);
|
||||
LayerGroup& layerGroup(LayeredTextures::TextureCategory);
|
||||
|
||||
const std::vector<std::shared_ptr<LayerGroup>>& layerGroups() const;
|
||||
|
||||
void update();
|
||||
void reset(bool includingInactive = false);
|
||||
|
||||
private:
|
||||
|
||||
std::vector<std::shared_ptr<LayerGroup>> layerGroups;
|
||||
std::vector<std::shared_ptr<LayerGroup>> _layerGroups;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user