Fix transferfunction usage so it binds texture

This commit is contained in:
Jonathan Grangien
2018-05-04 14:53:04 -04:00
parent c3d0267211
commit 58f563ffae
8 changed files with 17 additions and 24 deletions

View File

@@ -43,7 +43,7 @@ public:
void setPath(const std::string& filepath);
ghoul::opengl::Texture& getTexture();
void bind();
void updateTexture();
void update();
glm::vec4 sample(size_t t);
size_t width();
void setCallback(TfChangedCallback callback);

View File

@@ -153,7 +153,7 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict
, _transferFunctionPath(TransferFunctionInfo)
, _cache(CacheInfo)
, _raycaster(nullptr)
, _transferFunctionHandler(nullptr)
, _transferFunction(nullptr)
{
glm::vec3 dimensions;
@@ -172,9 +172,7 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict
std::string transferFunctionPath;
if (dictionary.getValue(KeyTransferFunction, transferFunctionPath)) {
_transferFunctionPath = transferFunctionPath;
_transferFunctionHandler = std::make_shared<volume::TransferFunctionHandler>(
_transferFunctionPath
);
_transferFunction = std::make_shared<TransferFunction>(_transferFunctionPath);
}
std::string sourcePath;
@@ -263,11 +261,11 @@ void RenderableKameleonVolume::initializeGL() {
load();
_volumeTexture->uploadTexture();
_transferFunctionHandler->initialize();
// _transferFunctionHandler->initialize();
_raycaster = std::make_unique<volume::BasicVolumeRaycaster>(
_volumeTexture,
_transferFunctionHandler,
_transferFunction,
_clipPlanes
);
@@ -318,7 +316,7 @@ void RenderableKameleonVolume::initializeGL() {
addProperty(_gridType);
addProperty(_cache);
addPropertySubOwner(_clipPlanes.get());
addPropertySubOwner(_transferFunctionHandler.get());
// addPropertySubOwner(_transferFunctionHandler.get());
}
void RenderableKameleonVolume::updateRaycasterModelTransform() {

View File

@@ -30,7 +30,7 @@
#include <openspace/properties/stringproperty.h>
#include <openspace/util/boxgeometry.h>
#include <openspace/rendering/renderable.h>
#include <modules/volume/transferfunctionhandler.h>
#include <openspace/rendering/transferfunction.h>
#include <modules/kameleon/include/kameleonwrapper.h>
#include <modules/volume/rawvolume.h>
#include <modules/volume/rendering/basicvolumeraycaster.h>
@@ -93,7 +93,7 @@ private:
std::unique_ptr<volume::BasicVolumeRaycaster> _raycaster;
std::shared_ptr<ghoul::opengl::Texture> _volumeTexture;
std::shared_ptr<volume::TransferFunctionHandler> _transferFunctionHandler;
std::shared_ptr<TransferFunction> _transferFunction;
};
} // namespace kameleonvolume

View File

@@ -463,7 +463,7 @@ void RenderableMultiresVolume::initializeGL() {
success &= _atlasManager && _atlasManager->initialize();
_transferFunction->updateTexture();
_transferFunction->update();
success &= isReady();

View File

@@ -28,6 +28,7 @@
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/logging/consolelog.h>
#include <sstream>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
@@ -57,7 +58,6 @@ BasicVolumeRaycaster::BasicVolumeRaycaster(
, _rUpperBound(1.0)
{}
BasicVolumeRaycaster::~BasicVolumeRaycaster() {}
void BasicVolumeRaycaster::initialize() {
@@ -126,7 +126,7 @@ void BasicVolumeRaycaster::preRaycast(
_tfUnit = std::make_unique<ghoul::opengl::TextureUnit>();
_tfUnit->activate();
_transferFunction->getTexture()->bind();
_transferFunction->getTexture().bind();
// LINFOC("PRERAYCAST", "hello");
program.setUniform("transferFunction_" + id, _tfUnit->unitNumber());

View File

@@ -311,7 +311,7 @@ void RenderableTimeVaryingVolume::initializeGL() {
addProperty(_transferFunctionPath);
addProperty(_sourceDirectory);
addPropertySubOwner(_clipPlanes.get());
addPropertySubOwner(_transferFunctionHandler.get());
// addPropertySubOwner(_transferFunctionHandler.get());
addProperty(_triggerTimeJump);
addProperty(_jumpToTimestep);

View File

@@ -113,11 +113,6 @@ void TransferFunctionHandler::initialize() {
_saveTransferFunction.onChange([this]() {
saveEnvelopes();
});
// Use core package tf as well
_transferFunction->updateTexture();
LINFOC("TF_HANDLER", "handler initialized");
}
void TransferFunctionHandler::setHistogramProperty(std::shared_ptr<openspace::Histogram> histogram) {
@@ -162,7 +157,7 @@ void TransferFunctionHandler::saveEnvelopes() {
void TransferFunctionHandler::setFilepath(const std::string& path) {
_filePath = path;
// _transferFunction->updateTexture();
// _transferFunction->update();
}
ghoul::opengl::Texture& TransferFunctionHandler::getTexture() {

View File

@@ -87,11 +87,11 @@ void TransferFunction::setPath(const std::string& filepath) {
ghoul::opengl::Texture& TransferFunction::getTexture() {
ghoul_assert(_texture != nullptr, "Transfer function is null");
updateTexture();
update();
return *_texture.get();
}
void TransferFunction::updateTexture() {
void TransferFunction::update() {
if (_needsUpdate) {
if (hasExtension(_filepath, "tf")) {
setTextureFromTxt();
@@ -240,12 +240,12 @@ glm::vec4 TransferFunction::sample(size_t offset) {
}
size_t TransferFunction::width() {
updateTexture();
update();
return _texture->width();
}
void TransferFunction::bind() {
updateTexture();
update();
_texture->bind();
}
}