Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit bab66780 authored by schultezub's avatar schultezub
Browse files

long commit of several refactorings - sorry for not splitting this up:

 * Fixed Issue #38: Made common GLSL header conform to the standards (no samplers in structs)
 * Fixed failing destruction of OpenGL buffers when destructing GeometryData from threads without OpenGL context
 * Fixed wrong pointers in GLContexts due to using this pointer of incompletely constructed class

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@463 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 3e66024d
...@@ -47,8 +47,8 @@ using namespace campvis; ...@@ -47,8 +47,8 @@ using namespace campvis;
**/ **/
int main(int argc, char** argv) { int main(int argc, char** argv) {
CampVisApplication app(argc, argv); CampVisApplication app(argc, argv);
app.addVisualizationPipeline("Advanced Ultrasound Visualization", new AdvancedUsVis()); //app.addVisualizationPipeline("Advanced Ultrasound Visualization", new AdvancedUsVis());
//app.addVisualizationPipeline("IXPV", new IxpvDemo()); app.addVisualizationPipeline("IXPV", new IxpvDemo());
//app.addVisualizationPipeline("SliceVis", new SliceVis()); //app.addVisualizationPipeline("SliceVis", new SliceVis());
//app.addVisualizationPipeline("DVRVis", new DVRVis()); //app.addVisualizationPipeline("DVRVis", new DVRVis());
#ifdef HAS_KISSCL #ifdef HAS_KISSCL
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
namespace campvis { namespace campvis {
const std::string TumVisPainter::loggerCat_ = "CAMPVis.core.TumVisPainter"; const std::string TumVisPainter::loggerCat_ = "CAMPVis.core.TumVisPainter";
TumVisPainter::TumVisPainter(tgt::QtThreadedCanvas* canvas, VisualizationPipeline* pipeline) TumVisPainter::TumVisPainter(tgt::GLCanvas* canvas, VisualizationPipeline* pipeline)
: Runnable() : Runnable()
, tgt::Painter(canvas) , tgt::Painter(canvas)
, _pipeline(0) , _pipeline(0)
...@@ -107,7 +107,7 @@ namespace campvis { ...@@ -107,7 +107,7 @@ namespace campvis {
// bind input textures // bind input textures
tgt::TextureUnit colorUnit, depthUnit; tgt::TextureUnit colorUnit, depthUnit;
image->bind(_copyShader, &colorUnit, &depthUnit); image->bind(_copyShader, colorUnit, depthUnit);
LGL_ERROR; LGL_ERROR;
// execute the shader // execute the shader
......
...@@ -62,7 +62,7 @@ namespace campvis { ...@@ -62,7 +62,7 @@ namespace campvis {
* \param canvas Canvas to render on * \param canvas Canvas to render on
* \param pipeline Pipeline to render * \param pipeline Pipeline to render
*/ */
TumVisPainter(tgt::QtThreadedCanvas* canvas, VisualizationPipeline* pipeline); TumVisPainter(tgt::GLCanvas* canvas, VisualizationPipeline* pipeline);
/** /**
* Destructor, stops and waits for the rendering thread if it's still running. * Destructor, stops and waits for the rendering thread if it's still running.
......
...@@ -36,9 +36,18 @@ out vec4 out_Color; ...@@ -36,9 +36,18 @@ out vec4 out_Color;
#include "tools/texture3d.frag" #include "tools/texture3d.frag"
#include "tools/transferfunction.frag" #include "tools/transferfunction.frag"
uniform Texture2D _texture2d; // 2D texture
uniform Texture3D _texture3d; uniform sampler2D _texture2d;
uniform TransferFunction1D _transferFunction; uniform TextureParameters2D _2dTextureParams;
// 3D texture
uniform sampler3D _texture3d;
uniform TextureParameters3D _3dTextureParams;
// Transfer Function
uniform sampler1D _transferFunction;
uniform TFParameters1D _transferFunctionParams;
uniform bool _is3d; uniform bool _is3d;
uniform int _sliceNumber; uniform int _sliceNumber;
uniform vec4 _color; uniform vec4 _color;
...@@ -51,26 +60,26 @@ void main() { ...@@ -51,26 +60,26 @@ void main() {
if (_sliceNumber < 0) { if (_sliceNumber < 0) {
// perform MIP // perform MIP
out_Color = vec4(0.0); out_Color = vec4(0.0);
for (float slice = 0.0; slice < 1.0; slice += _texture3d._sizeRCP.z) { for (float slice = 0.0; slice < 1.0; slice += _3dTextureParams._sizeRCP.z) {
out_Color = max(out_Color, lookupTF(_transferFunction, getElement3DNormalized(_texture3d, vec3(ex_TexCoord.xy, slice)).a)); out_Color = max(out_Color, lookupTF(_transferFunction, _transferFunctionParams, getElement3DNormalized(_texture3d, _3dTextureParams, vec3(ex_TexCoord.xy, slice)).a));
} }
} }
else { else {
// render the corresponding slice // render the corresponding slice
vec3 coord = vec3(ex_TexCoord.xy, (_sliceNumber + 0.5) / (_texture3d._size.z)); vec3 coord = vec3(ex_TexCoord.xy, (_sliceNumber + 0.5) / (_3dTextureParams._size.z));
out_Color = lookupTF(_transferFunction, getElement3DNormalized(_texture3d, coord).a); out_Color = lookupTF(_transferFunction, _transferFunctionParams, getElement3DNormalized(_texture3d, _3dTextureParams, coord).a);
} }
} }
else { else {
vec4 texel = getElement2DNormalized(_texture2d, ex_TexCoord.xy); vec4 texel = getElement2DNormalized(_texture2d, _2dTextureParams, ex_TexCoord.xy);
if (_texture2d._numChannels == 1) { if (_2dTextureParams._numChannels == 1) {
out_Color = lookupTF(_transferFunction, texel.a); out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
} }
else if (_texture2d._numChannels == 3) { else if (_2dTextureParams._numChannels == 3) {
out_Color = vec4(abs(texel.rgb), 1.0); out_Color = vec4(abs(texel.rgb), 1.0);
} }
else if (_texture2d._numChannels == 4) { else if (_2dTextureParams._numChannels == 4) {
out_Color = (abs(texel) - vec4(_transferFunction._intensityDomain.x)) / (_transferFunction._intensityDomain.y - _transferFunction._intensityDomain.x); out_Color = (abs(texel) - vec4(_transferFunctionParams._intensityDomain.x)) / (_transferFunctionParams._intensityDomain.y - _transferFunctionParams._intensityDomain.x);
} }
else { else {
out_Color = vec4(0.1, 0.6, 1.0, 0.75); out_Color = vec4(0.1, 0.6, 1.0, 0.75);
......
...@@ -134,8 +134,8 @@ namespace campvis { ...@@ -134,8 +134,8 @@ namespace campvis {
tgt::TextureUnit tfUnit, unit2d, unit3d; tgt::TextureUnit tfUnit, unit2d, unit3d;
p_transferFunction.getTF()->bind(_paintShader, tfUnit); p_transferFunction.getTF()->bind(_paintShader, tfUnit);
_paintShader->setUniform("_texture2d._texture", unit2d.getUnitNumber()); _paintShader->setUniform("_texture2d", unit2d.getUnitNumber());
_paintShader->setUniform("_texture3d._texture", unit3d.getUnitNumber()); _paintShader->setUniform("_texture3d", unit3d.getUnitNumber());
for (int y = 0; y < _numTiles.y; ++y) { for (int y = 0; y < _numTiles.y; ++y) {
for (int x = 0; x < _numTiles.x; ++x) { for (int x = 0; x < _numTiles.x; ++x) {
...@@ -162,9 +162,9 @@ namespace campvis { ...@@ -162,9 +162,9 @@ namespace campvis {
unit2d.activate(); unit2d.activate();
texture->bind(); texture->bind();
_paintShader->setUniform("_is3d", false); _paintShader->setUniform("_is3d", false);
_paintShader->setUniform("_texture2d._size", tgt::vec2(texture->getDimensions().xy())); _paintShader->setUniform("_2dTextureParams._size", tgt::vec2(texture->getDimensions().xy()));
_paintShader->setUniform("_texture2d._sizeRCP", tgt::vec2(1.f) / tgt::vec2(texture->getDimensions().xy())); _paintShader->setUniform("_2dTextureParams._sizeRCP", tgt::vec2(1.f) / tgt::vec2(texture->getDimensions().xy()));
_paintShader->setUniform("_texture2d._numChannels", static_cast<int>(texture->getNumChannels())); _paintShader->setUniform("_2dTextureParams._numChannels", static_cast<int>(texture->getNumChannels()));
} }
else { else {
// clamp current slice to texture size, since this can't be done in event handler: // clamp current slice to texture size, since this can't be done in event handler:
...@@ -174,9 +174,9 @@ namespace campvis { ...@@ -174,9 +174,9 @@ namespace campvis {
texture->bind(); texture->bind();
_paintShader->setUniform("_is3d", true); _paintShader->setUniform("_is3d", true);
_paintShader->setUniform("_sliceNumber", p_currentSlice.getValue()); _paintShader->setUniform("_sliceNumber", p_currentSlice.getValue());
_paintShader->setUniform("_texture3d._size", tgt::vec3(texture->getDimensions())); _paintShader->setUniform("_3dTextureParams._size", tgt::vec3(texture->getDimensions()));
_paintShader->setUniform("_texture3d._sizeRCP", tgt::vec3(1.f) / tgt::vec3(texture->getDimensions())); _paintShader->setUniform("_3dTextureParams._sizeRCP", tgt::vec3(1.f) / tgt::vec3(texture->getDimensions()));
_paintShader->setUniform("_texture2d._numChannels", static_cast<int>(texture->getNumChannels())); _paintShader->setUniform("_3dTextureParams._numChannels", static_cast<int>(texture->getNumChannels()));
} }
_paintShader->setIgnoreUniformLocationError(false); _paintShader->setIgnoreUniformLocationError(false);
......
...@@ -85,7 +85,7 @@ namespace campvis { ...@@ -85,7 +85,7 @@ namespace campvis {
_texture = 0; _texture = 0;
} }
void AbstractTransferFunction::bind(tgt::Shader* shader, const tgt::TextureUnit& texUnit, const std::string& transFuncUniform /*= "_transferFunction"*/) { void AbstractTransferFunction::bind(tgt::Shader* shader, const tgt::TextureUnit& texUnit, const std::string& transFuncUniform /*= "_transferFunction"*/, const std::string& transFuncParamsUniform /*= "_transferFunctionParameters"*/) {
tgtAssert(shader != 0, "Shader must not be 0."); tgtAssert(shader != 0, "Shader must not be 0.");
{ {
...@@ -103,13 +103,13 @@ namespace campvis { ...@@ -103,13 +103,13 @@ namespace campvis {
bool tmp = shader->getIgnoreUniformLocationError(); bool tmp = shader->getIgnoreUniformLocationError();
shader->setIgnoreUniformLocationError(true); shader->setIgnoreUniformLocationError(true);
shader->setUniform(transFuncUniform + "._texture", texUnit.getUnitNumber()); shader->setUniform(transFuncUniform, texUnit.getUnitNumber());
switch (getDimensionality()) { switch (getDimensionality()) {
case 1: case 1:
shader->setUniform(transFuncUniform + "._intensityDomain", tgt::vec2(_intensityDomain)); shader->setUniform(transFuncParamsUniform + "._intensityDomain", tgt::vec2(_intensityDomain));
break; break;
case 2: case 2:
shader->setUniform(transFuncUniform + "._intensityDomainX", tgt::vec2(_intensityDomain)); shader->setUniform(transFuncParamsUniform + "._intensityDomainX", tgt::vec2(_intensityDomain));
break; break;
default: default:
tgtAssert(false, "Unsupported TF dimensionality!"); tgtAssert(false, "Unsupported TF dimensionality!");
......
...@@ -95,9 +95,10 @@ namespace campvis { ...@@ -95,9 +95,10 @@ namespace campvis {
* \note Calling thread must have a valid OpenGL context. * \note Calling thread must have a valid OpenGL context.
* \param shader Shader used for rendering * \param shader Shader used for rendering
* \param texUnit Texture unit to bind texture to * \param texUnit Texture unit to bind texture to
* \param transFuncUniform Uniform name to store the TF struct * \param transFuncUniform Uniform name to store the TF sampler
* \param transFuncParamsUniform Uniform name to store the TF parameters struct
*/ */
void bind(tgt::Shader* shader, const tgt::TextureUnit& texUnit, const std::string& transFuncUniform = "_transferFunction"); void bind(tgt::Shader* shader, const tgt::TextureUnit& texUnit, const std::string& transFuncUniform = "_transferFunction", const std::string& transFuncParamsUniform = "_transferFunctionParams");
/** /**
* Creates the OpenGL texture. * Creates the OpenGL texture.
......
...@@ -129,6 +129,8 @@ namespace campvis { ...@@ -129,6 +129,8 @@ namespace campvis {
} }
void FaceGeometry::createGLBuffers() const { void FaceGeometry::createGLBuffers() const {
GeometryData::createGLBuffers();
if (! _buffersInitialized) { if (! _buffersInitialized) {
try { try {
_verticesBuffer = new tgt::BufferObject(tgt::BufferObject::ARRAY_BUFFER, tgt::BufferObject::USAGE_STATIC_DRAW); _verticesBuffer = new tgt::BufferObject(tgt::BufferObject::ARRAY_BUFFER, tgt::BufferObject::USAGE_STATIC_DRAW);
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#include "tgt/buffer.h" #include "tgt/buffer.h"
#include "tgt/vertexarrayobject.h" #include "tgt/vertexarrayobject.h"
#include "tgt/qt/qtcontextmanager.h"
#include "core/tools/opengljobprocessor.h"
namespace campvis { namespace campvis {
GeometryData::GeometryData() GeometryData::GeometryData()
...@@ -40,6 +43,7 @@ namespace campvis { ...@@ -40,6 +43,7 @@ namespace campvis {
, _texCoordsBuffer(0) , _texCoordsBuffer(0)
, _colorsBuffer(0) , _colorsBuffer(0)
, _normalsBuffer(0) , _normalsBuffer(0)
, _context(0)
{ {
} }
...@@ -55,10 +59,10 @@ namespace campvis { ...@@ -55,10 +59,10 @@ namespace campvis {
} }
GeometryData::~GeometryData() { GeometryData::~GeometryData() {
delete _verticesBuffer; if (_buffersInitialized) {
delete _texCoordsBuffer; std::vector<tgt::BufferObject*> buffers(_buffers, _buffers + NUM_BUFFERS);
delete _colorsBuffer; GLJobProc.enqueueJob(_context, makeJobOnHeap(&GeometryData::deleteBuffers, buffers), OpenGLJobProcessor::LowPriorityJob);
delete _normalsBuffer; }
} }
GeometryData& GeometryData::operator=(const GeometryData& rhs) { GeometryData& GeometryData::operator=(const GeometryData& rhs) {
...@@ -68,22 +72,25 @@ namespace campvis { ...@@ -68,22 +72,25 @@ namespace campvis {
AbstractData::operator=(rhs); AbstractData::operator=(rhs);
// delete old VBOs and null pointers // delete old VBOs and null pointers
delete _verticesBuffer; if (_buffersInitialized) {
_verticesBuffer = 0; std::vector<tgt::BufferObject*> buffers(_buffers, _buffers + NUM_BUFFERS);
GLJobProc.enqueueJob(_context, makeJobOnHeap(&GeometryData::deleteBuffers, buffers), OpenGLJobProcessor::LowPriorityJob);
}
delete _texCoordsBuffer; _verticesBuffer = 0;
_texCoordsBuffer = 0; _texCoordsBuffer = 0;
delete _colorsBuffer;
_colorsBuffer = 0; _colorsBuffer = 0;
delete _normalsBuffer;
_normalsBuffer = 0; _normalsBuffer = 0;
_buffersInitialized = false; _buffersInitialized = false;
return *this; return *this;
} }
void GeometryData::deleteBuffers(std::vector<tgt::BufferObject*> buffers) {
for (std::vector<tgt::BufferObject*>::iterator it = buffers.begin(); it != buffers.end(); ++it)
delete *it;
}
size_t GeometryData::getVideoMemoryFootprint() const { size_t GeometryData::getVideoMemoryFootprint() const {
size_t sum = 0; size_t sum = 0;
...@@ -99,6 +106,11 @@ namespace campvis { ...@@ -99,6 +106,11 @@ namespace campvis {
return sum; return sum;
} }
void GeometryData::createGLBuffers() const {
if (! _buffersInitialized)
_context = CtxtMgr.getCurrentContext();
}
const tgt::BufferObject* GeometryData::getVerticesBuffer() const { const tgt::BufferObject* GeometryData::getVerticesBuffer() const {
return _verticesBuffer; return _verticesBuffer;
} }
......
...@@ -31,9 +31,11 @@ ...@@ -31,9 +31,11 @@
#define GEOMETRYDATA_H__ #define GEOMETRYDATA_H__
#include "core/datastructures/abstractdata.h" #include "core/datastructures/abstractdata.h"
#include <vector>
namespace tgt { namespace tgt {
class BufferObject; class BufferObject;
class QtCanvas;
} }
namespace campvis { namespace campvis {
...@@ -55,6 +57,8 @@ namespace campvis { ...@@ -55,6 +57,8 @@ namespace campvis {
GeometryData& operator=(const GeometryData& rhs); GeometryData& operator=(const GeometryData& rhs);
static void deleteBuffers(std::vector<tgt::BufferObject*> buffers);
virtual AbstractData* clone() const = 0; virtual AbstractData* clone() const = 0;
/// \see AbstractData::getVideoMemoryFootprint() /// \see AbstractData::getVideoMemoryFootprint()
...@@ -69,8 +73,9 @@ namespace campvis { ...@@ -69,8 +73,9 @@ namespace campvis {
/** /**
* Creates the OpenGL VBOs and the VAO for this geometry. * Creates the OpenGL VBOs and the VAO for this geometry.
* Must be called from a valid OpenGL context. * Must be called from a valid OpenGL context.
* \note When overwriting this method, make sure to call base class method first!
*/ */
virtual void createGLBuffers() const = 0; virtual void createGLBuffers() const;
const tgt::BufferObject* getVerticesBuffer() const; const tgt::BufferObject* getVerticesBuffer() const;
...@@ -83,10 +88,22 @@ namespace campvis { ...@@ -83,10 +88,22 @@ namespace campvis {
protected: protected:
// mutable to support const lazy initialization // mutable to support const lazy initialization
mutable bool _buffersInitialized; mutable bool _buffersInitialized;
mutable tgt::BufferObject* _verticesBuffer;
mutable tgt::BufferObject* _texCoordsBuffer; enum { NUM_BUFFERS = 4 };
mutable tgt::BufferObject* _colorsBuffer;
mutable tgt::BufferObject* _normalsBuffer; union {
struct {
mutable tgt::BufferObject* _verticesBuffer;
mutable tgt::BufferObject* _texCoordsBuffer;
mutable tgt::BufferObject* _colorsBuffer;
mutable tgt::BufferObject* _normalsBuffer;
};
mutable tgt::BufferObject* _buffers[NUM_BUFFERS];
};
private:
mutable tgt::QtCanvas* _context; ///< OpenGL context the buffers were created in (so that they can be deleted correctly)
}; };
} }
......
...@@ -184,7 +184,7 @@ namespace campvis { ...@@ -184,7 +184,7 @@ namespace campvis {
_texture->bind(); _texture->bind();
} }
void ImageRepresentationGL::bind(tgt::Shader* shader, const tgt::TextureUnit& texUnit, const std::string& texUniform /*= "_texture"*/) const { void ImageRepresentationGL::bind(tgt::Shader* shader, const tgt::TextureUnit& texUnit, const std::string& texUniform /*= "_texture"*/, const std::string& texParamsUniform) const {
bind(texUnit); bind(texUnit);
bool tmp = shader->getIgnoreUniformLocationError(); bool tmp = shader->getIgnoreUniformLocationError();
shader->setIgnoreUniformLocationError(true); shader->setIgnoreUniformLocationError(true);
...@@ -195,21 +195,21 @@ namespace campvis { ...@@ -195,21 +195,21 @@ namespace campvis {
break; break;
case 2: case 2:
shader->setUniform(texUniform + "._texture", texUnit.getUnitNumber()); shader->setUniform(texUniform, texUnit.getUnitNumber());
shader->setUniform(texUniform + "._size", tgt::vec2(getSize().xy())); shader->setUniform(texParamsUniform + "._size", tgt::vec2(getSize().xy()));
shader->setUniform(texUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(getSize().xy())); shader->setUniform(texParamsUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(getSize().xy()));
shader->setUniform(texUniform + "._numChannels", static_cast<int>(_parent->getNumChannels())); shader->setUniform(texParamsUniform + "._numChannels", static_cast<int>(_parent->getNumChannels()));
break; break;
case 3: case 3:
shader->setUniform(texUniform + "._texture", texUnit.getUnitNumber()); shader->setUniform(texUniform, texUnit.getUnitNumber());
shader->setUniform(texUniform + "._size", tgt::vec3(getSize())); shader->setUniform(texParamsUniform + "._size", tgt::vec3(getSize()));
shader->setUniform(texUniform + "._sizeRCP", tgt::vec3(1.f) / tgt::vec3(getSize())); shader->setUniform(texParamsUniform + "._sizeRCP", tgt::vec3(1.f) / tgt::vec3(getSize()));
shader->setUniform(texUniform + "._numChannels", static_cast<int>(_parent->getNumChannels())); shader->setUniform(texParamsUniform + "._numChannels", static_cast<int>(_parent->getNumChannels()));
shader->setUniform(texUniform + "._voxelSize", _parent->getMappingInformation().getVoxelSize()); shader->setUniform(texParamsUniform + "._voxelSize", _parent->getMappingInformation().getVoxelSize());
shader->setUniform(texUniform + "._voxelSizeRCP", tgt::vec3(1.f) / _parent->getMappingInformation().getVoxelSize()); shader->setUniform(texParamsUniform + "._voxelSizeRCP", tgt::vec3(1.f) / _parent->getMappingInformation().getVoxelSize());
shader->setUniform(texUniform + "._textureToWorldMatrix", _parent->getMappingInformation().getTextureToWorldMatrix()); shader->setUniform(texParamsUniform + "._textureToWorldMatrix", _parent->getMappingInformation().getTextureToWorldMatrix());
shader->setUniform(texUniform + "._realWorldMapping", tgt::vec2(_parent->getMappingInformation().getRealWorldMapping()._shift, _parent->getMappingInformation().getRealWorldMapping()._scale)); shader->setUniform(texParamsUniform + "._realWorldMapping", tgt::vec2(_parent->getMappingInformation().getRealWorldMapping()._shift, _parent->getMappingInformation().getRealWorldMapping()._scale));
break; break;
default: default:
......
...@@ -105,27 +105,18 @@ namespace campvis { ...@@ -105,27 +105,18 @@ namespace campvis {
virtual ImageRepresentationGL* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const; virtual ImageRepresentationGL* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Binds the texture without activating a texture unit.
*/
void bind() const;
/**
* Activates the texture unit \a texUnit and binds the texture.
* \param texUnit Texture unit to activate
*/
void bind(const tgt::TextureUnit& texUnit) const;
/** /**
* Binds the image to the given shader using \a texUnit as texture unit and \a texUniform as shader uniform. * Binds the image to the given shader using \a texUnit as texture unit and \a texUniform as shader uniform.
* \param shader Shader to bind image and set uniforms to. * \param shader Shader to bind image and set uniforms to.
* \param texUnit TextureUnit to bind image to. * \param texUnit TextureUnit to bind image to.
* \param texUniform Uniform name for the sampler. * \param texUniform Uniform name for the sampler.
* \param texParamsUniform Name for texture parameters struct uniform.
*/ */
void bind( void bind(
tgt::Shader* shader, tgt::Shader* shader,
const tgt::TextureUnit& texUnit, const tgt::TextureUnit& texUnit,
const std::string& texUniform = "_texture") const; const std::string& texUniform = "_texture",
const std::string& texParamsUniform = "_textureParams") const;
/** /**
* Gets the OpenGL texture. * Gets the OpenGL texture.
...@@ -171,6 +162,17 @@ namespace campvis { ...@@ -171,6 +162,17 @@ namespace campvis {
template<typename BASETYPE, size_t NUMCHANNELS> template<typename BASETYPE, size_t NUMCHANNELS>
ImageRepresentationGL(ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data); ImageRepresentationGL(ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data);
/**
* Binds the texture without activating a texture unit.
*/
void bind() const;
/**
* Activates the texture unit \a texUnit and binds the texture.
* \param texUnit Texture unit to activate
*/
void bind(const tgt::TextureUnit& texUnit) const;
/** /**
* Creates the OpenGL texture from the given pointer \a wtp. * Creates the OpenGL texture from the given pointer \a wtp.
* \param wtp WeaklyTypedPointer with source image data * \param wtp WeaklyTypedPointer with source image data
......
...@@ -135,42 +135,46 @@ namespace campvis { ...@@ -135,42 +135,46 @@ namespace campvis {
_fbo->deactivate(); _fbo->deactivate();
} }
void ImageRepresentationRenderTarget::bindColorTexture(size_t index /*= 0*/) const { void ImageRepresentationRenderTarget::bindColorTexture(tgt::Shader* shader, const tgt::TextureUnit& colorTexUnit, const std::string& colorTexUniform /*= "_colorTexture"*/, const std::string& texParamsUniform /*= "_texParams"*/, size_t index /*= 0*/) const {
tgtAssert(index < _colorTextures.size(), "Color texture index out of bounds!"); tgtAssert(index < _colorTextures.size(), "Color texture index out of bounds!");
_colorTextures[index]->bind(); bool tmp = shader->getIgnoreUniformLocationError();
} shader->setIgnoreUniformLocationError(true);
void ImageRepresentationRenderTarget::bindColorTexture(const tgt::TextureUnit& texUnit, size_t index /*= 0*/) const { bindColorTexture(colorTexUnit, index);
tgtAssert(index < _colorTextures.size(), "Color texture index out of bounds!"); shader->