Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit a914bcbd authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Merge branch 'GlRefactoring' of /mnt/bigone/git/repositories/berge/campvis into development

parents 73f46321 fe24467e
......@@ -106,10 +106,13 @@ namespace campvis {
// ensure matching OpenGL specs
if (GpuCaps.getGlVersion() < tgt::GpuCapabilities::GlVersion::TGT_GL_VERSION_3_3) {
LERROR("Your system does not support OpenGL 3.3, which is mandatory. CAMPVis will probably not work as intendet.");
LERROR("Your system does not support OpenGL 3.3, which is mandatory. CAMPVis will probably not work as intended.");
}
if (GpuCaps.getShaderVersion() < tgt::GpuCapabilities::GlVersion::SHADER_VERSION_330) {
LERROR("Your system does not support GLSL Shader Version 3.30, which is mandatory. CAMPVis will probably not work as intendet.");
LERROR("Your system does not support GLSL Shader Version 3.30, which is mandatory. CAMPVis will probably not work as intended.");
}
if (!GpuCaps.isNpotSupported() && !GpuCaps.areTextureRectanglesSupported()) {
LERROR("Neither non-power-of-two textures nor texture rectangles seem to be supported. CAMPVis will probably not work as intended.");
}
QuadRenderer::init();
......@@ -144,6 +147,15 @@ namespace campvis {
CLRtm.addPath(basePath);
CLRtm.addPath(basePath + "/core/cl");
}
#ifdef CAMPVIS_SOURCE_DIR
{
std::string sourcePath = CAMPVIS_SOURCE_DIR;
CLRtm.addPath(sourcePath);
CLRtm.addPath(sourcePath + "/core/glsl");
}
#endif
#endif
}
......
......@@ -31,14 +31,16 @@
#include "tgt/assert.h"
#include "tgt/camera.h"
#include "tgt/quadric.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "tgt/qt/qtthreadedcanvas.h"
#include "tgt/qt/qtglcontext.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/quadric.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/datastructures/renderdata.h"
#include "core/pipeline/visualizationpipeline.h"
#include "core/tools/job.h"
#include "core/tools/opengljobprocessor.h"
......@@ -95,9 +97,9 @@ namespace campvis {
glViewport(0, 0, size.x, size.y);
// try get Data
ImageRepresentationRenderTarget::ScopedRepresentation image(_pipeline->getDataContainer(), _pipeline->getRenderTargetID());
DataContainer::ScopedTypedData<RenderData> rd(_pipeline->getDataContainer(), _pipeline->getRenderTargetID());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (image != 0) {
if (rd != 0) {
// activate shader
_copyShader->activate();
_copyShader->setIgnoreUniformLocationError(true);
......@@ -107,7 +109,7 @@ namespace campvis {
// bind input textures
tgt::TextureUnit colorUnit, depthUnit;
image->bind(_copyShader, colorUnit, depthUnit);
rd->bind(_copyShader, colorUnit, depthUnit);
LGL_ERROR;
// execute the shader
......
......@@ -35,7 +35,7 @@
#include "core/datastructures/datacontainer.h"
#include "core/datastructures/datahandle.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/datastructures/renderdata.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/facegeometry.h"
#include "core/tools/job.h"
......@@ -283,16 +283,24 @@ namespace campvis {
int maxSlices = 1;
for (std::map<QString, QtDataHandle>::iterator it = _handles.begin(); it != _handles.end(); ++it) {
if (const ImageData* img = dynamic_cast<const ImageData*>(it->second.getData())) {
if (const ImageRepresentationRenderTarget* imgRT = img->getRepresentation<ImageRepresentationRenderTarget>(false)) {
for (size_t i = 0; i < imgRT->getNumColorTextures(); ++i)
_textures.push_back(imgRT->getColorTexture(i));
_textures.push_back(imgRT->getDepthTexture());
}
else if (const ImageRepresentationGL* imgGL = img->getRepresentation<ImageRepresentationGL>()) {
if (const ImageRepresentationGL* imgGL = img->getRepresentation<ImageRepresentationGL>()) {
_textures.push_back(imgGL->getTexture());
maxSlices = std::max(maxSlices, imgGL->getTexture()->getDimensions().z);
}
}
else if (const RenderData* rd = dynamic_cast<const RenderData*>(it->second.getData())) {
for (size_t i = 0; i < rd->getNumColorTextures(); ++i) {
const ImageRepresentationGL* imgGL = rd->getColorTexture(i)->getRepresentation<ImageRepresentationGL>();
if (imgGL)
_textures.push_back(imgGL->getTexture());
}
if (rd->hasDepthTexture()) {
const ImageRepresentationGL* imgGL = rd->getDepthTexture()->getRepresentation<ImageRepresentationGL>();
if (imgGL)
_textures.push_back(imgGL->getTexture());
}
}
}
if (maxSlices == 1)
......
......@@ -30,6 +30,7 @@
#include "datacontainerinspectorwidget.h"
#include "tgt/assert.h"
#include "tgt/logmanager.h"
#include "tgt/filesystem.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
......@@ -49,7 +50,7 @@
#include "core/datastructures/facegeometry.h"
#include "core/datastructures/geometrydata.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/datastructures/renderdata.h"
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
#include "modules/columbia/datastructures/fiberdata.h"
......@@ -62,6 +63,8 @@
namespace campvis {
const std::string DataContainerInspectorWidget::loggerCat_ = "CAMPVis.application.DataContainerInspectorWidget";
DataContainerInspectorWidget::DataContainerInspectorWidget(QWidget* parent)
: QWidget(parent)
, _inited(false)
......@@ -308,21 +311,19 @@ namespace campvis {
// only consider non-empty DataHandles that are ImageData and have render target representations
if (handle.getData() != 0) {
if (const ImageData* tester = dynamic_cast<const ImageData*>(handle.getData())) {
if (const ImageRepresentationRenderTarget* repRT = tester->getRepresentation<ImageRepresentationRenderTarget>(false)) {
QString dialogCaption = "Export " + idxName.data(Qt::DisplayRole).toString() + " as Image";
QString directory = tr("");
const QString fileFilter = tr("*.png;;PNG images (*.png)");
QString filename = QFileDialog::getSaveFileName(this, dialogCaption, directory, fileFilter);
if (! filename.isEmpty()) {
// Texture access needs OpenGL context - dispatch method call:
GLJobProc.enqueueJob(
_canvas,
makeJobOnHeap(&DataContainerInspectorWidget::saveToFile, handle, filename.toStdString()),
OpenGLJobProcessor::SerialJob);
}
if (dynamic_cast<const ImageData*>(handle.getData()) || dynamic_cast<const RenderData*>(handle.getData())) {
QString dialogCaption = "Export " + idxName.data(Qt::DisplayRole).toString() + " as Image";
QString directory = tr("");
const QString fileFilter = tr("*.png;;PNG images (*.png)");
QString filename = QFileDialog::getSaveFileName(this, dialogCaption, directory, fileFilter);
if (! filename.isEmpty()) {
// Texture access needs OpenGL context - dispatch method call:
GLJobProc.enqueueJob(
_canvas,
makeJobOnHeap(&DataContainerInspectorWidget::saveToFile, handle, filename.toStdString()),
OpenGLJobProcessor::SerialJob);
}
}
}
......@@ -336,13 +337,35 @@ namespace campvis {
return;
}
// we did the test before, hence, static_cast ist safe
const ImageRepresentationRenderTarget* repRT = static_cast<const ImageData*>(handle.getData())->getRepresentation<ImageRepresentationRenderTarget>(false);
tgtAssert(repRT != 0, "DataHandle must be of type ImageData having an ImageRepresentationRenderTarget inside - otherwise you're not allowed to call this method!");
// get the ImageData object (either directly or from the RenderData)
const ImageData* id = 0;
if (const RenderData* tester = dynamic_cast<const RenderData*>(handle.getData())) {
id = tester->getColorTexture(0);
}
else if (const ImageData* tester = dynamic_cast<const ImageData*>(handle.getData())) {
id = tester;
}
else {
LERROR("Could not extract image to save.");
return;
}
// extract the data
WeaklyTypedPointer wtp(WeaklyTypedPointer::UINT8, 1, 0);
const ImageRepresentationGL* repGL = id->getRepresentation<ImageRepresentationGL>(false);
if (repGL != 0) // if it's a GL texture, download it (we do not want to use the automatic conversion method here)
wtp = repGL->getWeaklyTypedPointer();
else {
const ImageRepresentationLocal* repLocal = id->getRepresentation<ImageRepresentationLocal>(true);
if (repLocal != 0)
wtp = repLocal->getWeaklyTypedPointer();
}
if (wtp._pointer == 0) {
LERROR("Could not extract image to save.");
return;
}
// get color buffer content
GLubyte* colorBuffer = repRT->getColorTexture()->downloadTextureToBuffer(GL_RGBA, GL_UNSIGNED_SHORT);
tgt::ivec2 size = repRT->getSize().xy();
// create Devil image from image data and write it to file
ILuint img;
......@@ -350,14 +373,13 @@ namespace campvis {
ilBindImage(img);
// put pixels into IL-Image
ilTexImage(size.x, size.y, 1, 4, IL_RGBA, IL_UNSIGNED_SHORT, colorBuffer);
tgt::ivec2 size = id->getSize().xy();
ilTexImage(size.x, size.y, 1, static_cast<ILubyte>(wtp._numChannels), wtp.getIlFormat(), wtp.getIlDataType(), wtp._pointer);
ilEnable(IL_FILE_OVERWRITE);
ilResetWrite();
ILboolean success = ilSaveImage(filename.c_str());
ilDeleteImages(1, &img);
delete[] colorBuffer;
if (!success) {
LERRORC("CAMPVis.application.DataContainerInspectorWidget", "Could not save image to file: " << ilGetError());
}
......
......@@ -138,7 +138,7 @@ namespace campvis {
/**
* Saves the Image in \a handle to the file \a filename.
* \note This method must be called with a valid OpenGL context!
* \param handle DataHandle containing the image to save. Must be of type ImageData having an ImageRepresentationRenderTarget inside!
* \param handle DataHandle containing the image to save. Must contain ImageData or RenderData!
* \param filename Filename for the file to save.
*/
static void saveToFile(DataHandle handle, std::string filename);
......@@ -169,6 +169,8 @@ namespace campvis {
QLabel* _lblSize;
QLabel* _lblBounds;
QPushButton* _btnSaveToFile;
static const std::string loggerCat_;
};
}
......
......@@ -40,7 +40,6 @@
#include "core/datastructures/meshgeometry.h"
#include "core/datastructures/imagerepresentationdisk.h"
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/datastructures/imagerepresentationgl.h"
#include <QHeaderView>
......
......@@ -37,7 +37,6 @@
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationdisk.h"
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#ifdef CAMPVIS_HAS_MODULE_ITK
#include "modules/itk/core/genericimagerepresentationitk.h"
#endif
......
......@@ -125,6 +125,7 @@ namespace campvis {
return convertToGenericLocal(tester, tester->getImageData());
}
else if (const ImageRepresentationGL* tester = dynamic_cast<const ImageRepresentationGL*>(source)) {
// FIXME: this here deadlocks, if called from OpenGL context (GLJobProc)!!!
tgt::GLCanvas* context = GLJobProc.iKnowWhatImDoingGetArbitraryContext();
ImageRepresentationLocal* toReturn = 0;
GLJobProc.pause();
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "imagerepresentationrendertarget.h"
#include "tgt/assert.h"
#include "tgt/gpucapabilities.h"
#include "tgt/logmanager.h"
#include "tgt/shadermanager.h"
#include "tgt/tgt_gl.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationgl.h"
namespace campvis {
const std::string ImageRepresentationRenderTarget::loggerCat_ = "CAMPVis.core.datastructures.ImageRepresentationRenderTarget";
ImageRepresentationRenderTarget* ImageRepresentationRenderTarget::create(ImageData* parent, GLint internalFormatColor /*= GL_RGBA8*/, GLint internalFormatDepth /*= GL_DEPTH_COMPONENT24*/) {
ImageRepresentationRenderTarget* toReturn = new ImageRepresentationRenderTarget(parent, internalFormatColor, internalFormatDepth);
toReturn->addToParent();
return toReturn;
}
std::pair<ImageData*, ImageRepresentationRenderTarget*> ImageRepresentationRenderTarget::createWithImageData(const tgt::svec2& size, GLint internalFormatColor /*= GL_RGBA8*/, GLint internalFormatDepth /*= GL_DEPTH_COMPONENT24*/) {
ImageData* id = new ImageData(2, tgt::svec3(size, 1), 4);
ImageRepresentationRenderTarget* toReturn = new ImageRepresentationRenderTarget(id, internalFormatColor, internalFormatDepth);
toReturn->addToParent();
return std::make_pair(id, toReturn);
}
ImageRepresentationRenderTarget::ImageRepresentationRenderTarget(ImageData* parent, GLint internalFormatColor /*= GL_RGBA8*/, GLint internalFormatDepth /*= GL_DEPTH_COMPONENT24*/)
: GenericAbstractImageRepresentation<ImageRepresentationRenderTarget>(parent)
, _colorTextures(0)
, _depthTexture(0)
, _fbo(0)
{
tgtAssert(parent->getSize().z == 1, "RenderTargets are only two-dimensional, expected parent image size.z == 1.");
if (!GpuCaps.isNpotSupported() && !GpuCaps.areTextureRectanglesSupported()) {
LWARNING("Neither non-power-of-two textures nor texture rectangles seem to be supported!");
}
_fbo = new tgt::FramebufferObject();
if (!_fbo) {
LERROR("Failed to initialize framebuffer object!");
return;
}
createAndAttachTexture(internalFormatColor);
createAndAttachTexture(internalFormatDepth);
tgtAssert(_colorTextures.front() != 0, "Color texture is 0, something went terribly wrong...");
tgtAssert(_depthTexture != 0, "Depth texture is 0, something went terribly wrong...");
tgtAssert(_fbo != 0, "Framebuffer object is 0, something went terribly wrong...");
}
ImageRepresentationRenderTarget::ImageRepresentationRenderTarget(ImageData* parent, const ImageRepresentationGL* colorTexture, const ImageRepresentationGL* depthTexture /* = 0 */)
: GenericAbstractImageRepresentation<ImageRepresentationRenderTarget>(parent)
, _colorTextures(0)
, _depthTexture(0)
, _fbo(0)
{
tgtAssert(parent->getSize().z == 1, "RenderTargets are only two-dimensional, expected parent image size.z == 1.");
tgtAssert(colorTexture != 0, "Color texture must not be 0.");
tgtAssert(parent->getSize() == colorTexture->getSize(), "Texture size must match parent image size");
tgtAssert(parent->getDimensionality() == colorTexture->getDimensionality(), "Texture dimensionality must match parent image dimensionality");
tgtAssert(depthTexture == 0 || parent->getSize() == depthTexture->getSize(), "Texture size must match parent image size");
tgtAssert(depthTexture == 0 || parent->getDimensionality() == depthTexture->getDimensionality(), "Texture dimensionality must match parent image dimensionality");
if (!GpuCaps.isNpotSupported() && !GpuCaps.areTextureRectanglesSupported()) {
LWARNING("Neither non-power-of-two textures nor texture rectangles seem to be supported!");
}
_fbo = new tgt::FramebufferObject();
if (!_fbo) {
LERROR("Failed to initialize framebuffer object!");
return;
}
// TODO: finish implementation!
tgtAssert(false, "Method not yet fully implemented!");
// _fbo->activate();
// tgt::Texture* cc = colorTexture->getTexture()
// _fbo->attachTexture(cc, GL_COLOR_ATTACHMENT0);
}
ImageRepresentationRenderTarget::~ImageRepresentationRenderTarget() {
// TODO: double check whether deleting FBOs without detaching their attachments is not harmful
// if (_fbo != 0) {
// _fbo->activate();
// _fbo->detachAll();
// _fbo->deactivate();
// }
delete _fbo;
for (std::vector<tgt::Texture*>::iterator it = _colorTextures.begin(); it != _colorTextures.end(); ++it)
delete *it;
delete _depthTexture;
}
void ImageRepresentationRenderTarget::activate() {
_fbo->activate();
glViewport(0, 0, static_cast<GLsizei>(getSize().x), static_cast<GLsizei>(getSize().y));
}
void ImageRepresentationRenderTarget::deactivate() {
_fbo->deactivate();
}
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!");
bool tmp = shader->getIgnoreUniformLocationError();
shader->setIgnoreUniformLocationError(true);
bindColorTexture(colorTexUnit, index);
shader->setUniform(colorTexUniform, colorTexUnit.getUnitNumber());
shader->setUniform(texParamsUniform + "._size", tgt::vec2(getSize().xy()));
shader->setUniform(texParamsUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(getSize().xy()));
shader->setUniform(texParamsUniform + "._numChannels", static_cast<int>(_parent->getNumChannels()));
shader->setIgnoreUniformLocationError(tmp);
}
void ImageRepresentationRenderTarget::bindDepthTexture(tgt::Shader* shader, const tgt::TextureUnit& depthTexUnit, const std::string& depthTexUniform /*= "_depthTexture"*/, const std::string& texParamsUniform /*= "_texParams"*/) const {
bool tmp = shader->getIgnoreUniformLocationError();
shader->setIgnoreUniformLocationError(true);
bindDepthTexture(depthTexUnit);
shader->setUniform(depthTexUniform, depthTexUnit.getUnitNumber());
shader->setUniform(texParamsUniform + "._size", tgt::vec2(getSize().xy()));
shader->setUniform(texParamsUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(getSize().xy()));
shader->setUniform(texParamsUniform + "._numChannels", static_cast<int>(_parent->getNumChannels()));
shader->setIgnoreUniformLocationError(tmp);
}
void ImageRepresentationRenderTarget::bind(tgt::Shader* shader, const tgt::TextureUnit& colorTexUnit, const tgt::TextureUnit& depthTexUnit, const std::string& colorTexUniform /*= "_colorTexture"*/, const std::string& depthTexUniform /*= "_depthTexture"*/, const std::string& texParamsUniform /*= "_texParams"*/, size_t index /*= 0*/) const {
tgtAssert(index < _colorTextures.size(), "Color texture index out of bounds!");
bool tmp = shader->getIgnoreUniformLocationError();
shader->setIgnoreUniformLocationError(true);
bindColorTexture(colorTexUnit, index);
bindDepthTexture(depthTexUnit);
shader->setUniform(colorTexUniform, colorTexUnit.getUnitNumber());
shader->setUniform(depthTexUniform, depthTexUnit.getUnitNumber());
shader->setUniform(texParamsUniform + "._size", tgt::vec2(getSize().xy()));
shader->setUniform(texParamsUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(getSize().xy()));
shader->setUniform(texParamsUniform + "._numChannels", static_cast<int>(_parent->getNumChannels()));
shader->setIgnoreUniformLocationError(tmp);
}
ImageRepresentationRenderTarget* ImageRepresentationRenderTarget::clone(ImageData* newParent) const {
tgtAssert(false, "To be implemented!");
return 0;
}
ImageRepresentationRenderTarget* ImageRepresentationRenderTarget::getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
tgtAssert(false, "To be implemented!");
return 0;
}
const tgt::Texture* ImageRepresentationRenderTarget::getColorTexture(size_t index /*= 0*/) const {
tgtAssert(index < _colorTextures.size(), "Color texture index out of bounds!");
return _colorTextures[index];
}
const tgt::Texture* ImageRepresentationRenderTarget::getDepthTexture() const {
return _depthTexture;
}
size_t ImageRepresentationRenderTarget::getNumColorTextures() const {
return _colorTextures.size();
}
void ImageRepresentationRenderTarget::createAndAttachTexture(GLint internalFormat) {
// do sanity tests:
GLenum attachment = 0;
switch(internalFormat) {
case GL_RGB:
case GL_RGB16F_ARB:
case GL_RGBA:
case GL_RGBA8:
case GL_RGBA16:
case GL_RGBA16F:
case GL_RGBA32F:
if (_colorTextures.size() >= static_cast<size_t>(GpuCaps.getMaxColorAttachments())) {
tgtAssert(false, "Tried to attach more color textures to FBO than supported!");
LWARNING("Tried to attach more color textures to FBO than supported, aborted.");
return;
}
attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + _colorTextures.size());
break;
case GL_DEPTH_COMPONENT16:
case GL_DEPTH_COMPONENT24:
#ifdef GL_DEPTH_COMPONENT32F
case GL_DEPTH_COMPONENT32F:
#endif
tgtAssert(_depthTexture == 0, "Tried to attach more than one depth texture.");
attachment = GL_DEPTH_ATTACHMENT;
break;
default:
tgtAssert(false, "Unknown internal format!");
}
// acqiure a new TextureUnit, so that we don't mess with other currently bound textures during texture upload...
tgt::TextureUnit rtUnit;
rtUnit.activate();
// Set OpenGL pixel alignment to 1 to avoid problems with NPOT textures
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// create texture
tgt::Texture* tex = 0;
switch(internalFormat) {
case GL_RGB:
tex = new tgt::Texture(0, getSize(), GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, tgt::Texture::LINEAR);
_colorTextures.push_back(tex);
break;
case GL_RGB16F_ARB:
tex = new tgt::Texture(0, getSize(), GL_RGB, GL_RGB16F_ARB, GL_FLOAT, tgt::Texture::LINEAR);
_colorTextures.push_back(tex);
break;
case GL_RGBA:
tex = new tgt::Texture(0, getSize(), GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, tgt::Texture::LINEAR);
_colorTextures.push_back(tex);
break;
case GL_RGBA8:
tex = new tgt::Texture(0, getSize(), GL_RGBA, GL_RGBA8, GL_UNSIGNED_BYTE, tgt::Texture::LINEAR);
_colorTextures.push_back(tex);
break;
case GL_RGBA16:
tex = new tgt::Texture(0, getSize(), GL_RGBA, GL_RGBA16, GL_UNSIGNED_SHORT, tgt::Texture::LINEAR);
_colorTextures.push_back(tex);
break;
case GL_RGBA16F:
tex = new tgt::Texture(0, getSize(), GL_RGBA, GL_RGBA16F, GL_FLOAT, tgt::Texture::LINEAR);
_colorTextures.push_back(tex);
break;
case GL_RGBA32F:
tex = new tgt::Texture(0, getSize(), GL_RGBA, GL_RGBA32F, GL_FLOAT, tgt::Texture::LINEAR);
_colorTextures.push_back(tex);
break;
case GL_DEPTH_COMPONENT16:
tex = new tgt::Texture(0, getSize(), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_FLOAT, tgt::Texture::LINEAR);
_depthTexture = tex;
break;
case GL_DEPTH_COMPONENT24:
tex = new tgt::Texture(0, getSize(), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT24, GL_FLOAT, tgt::Texture::LINEAR);
_depthTexture = tex;
break;
#ifdef GL_DEPTH_COMPONENT32F
case GL_DEPTH_COMPONENT32F:
tex = new tgt::Texture(0, getSize(), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT32F, GL_FLOAT, tgt::Texture::LINEAR);
break;
#endif
default:
tgtAssert(false, "Unknown internal format!");
}
tex->uploadTexture();
tex->setWrapping(tgt::Texture::CLAMP_TO_EDGE);
// attach texture to FBO
_fbo->activate();
_fbo->attachTexture(tex, attachment);
_fbo->isComplete();
_fbo->deactivate();
}
size_t ImageRepresentationRenderTarget::getLocalMemoryFootprint() const {
size_t sum = 0;
sum += sizeof(tgt::FramebufferObject);
sum += sizeof(tgt::Texture) * _colorTextures.size();
for (std::vector<tgt::