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 6d43b513 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Prototype implementation of OpenGL 3.3 geometry transfer functions (instead of intermediate mode)

parent 3a53f60e
......@@ -64,9 +64,14 @@ namespace campvis {
* Destructor, make sure to delete the OpenGL texture beforehand by calling deinit() with a valid OpenGL context!
*/
virtual ~GenericGeometryTransferFunction();
/**
* Initializes the Shader, hence, this methods has to be called from a thread with a valid OpenGL context!
*/
virtual void initShader();
/**
* Deletes the OpenGL texture, hence, this methods has to be called from a thread with a valid OpenGL context!
* Deletes the OpenGL texture and shader, hence, this methods has to be called from a thread with a valid OpenGL context!
*/
virtual void deinit();
......@@ -107,6 +112,7 @@ namespace campvis {
std::vector<T*> _geometries; ///< The list of transfer function geometries.
tgt::FramebufferObject* _fbo; ///< The FBO used for render into texture.
tgt::Shader* _shader; ///< Shader for rendering the TF into a texture
};
// ================================================================================================
......@@ -115,20 +121,36 @@ namespace campvis {
campvis::GenericGeometryTransferFunction<T>::GenericGeometryTransferFunction(const tgt::vec3& size, const tgt::vec2& intensityDomain /*= tgt::vec2(0.f, 1.f)*/)
: AbstractTransferFunction(size, intensityDomain)
, _fbo(0)
, _shader(0)
{
}
template<class T>
campvis::GenericGeometryTransferFunction<T>::~GenericGeometryTransferFunction() {
for (typename std::vector<T*>::iterator it = _geometries.begin(); it != _geometries.end(); ++it) {
(*it)->s_changed.disconnect(this);
delete *it;
}
template<class T>
void campvis::GenericGeometryTransferFunction<T>::initShader() {
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "core/glsl/passthrough.frag", "", false);
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
_shader->setAttributeLocation(2, "in_Color");
}
else {
LERROR("Could not create Shader for Rendering the TF into the lookup texture!");
}
}
template<class T>
void campvis::GenericGeometryTransferFunction<T>::deinit() {
for (typename std::vector<T*>::iterator it = _geometries.begin(); it != _geometries.end(); ++it) {
(*it)->s_changed.disconnect(this);
delete *it;
}
_geometries.clear();
if (_fbo != 0) {
_fbo->activate();
_fbo->detachAll();
......@@ -137,6 +159,8 @@ namespace campvis {
_fbo = 0;
}
ShdrMgr.dispose(_shader);
_shader = 0;
AbstractTransferFunction::deinit();
}
......@@ -183,6 +207,10 @@ namespace campvis {
template<class T>
void campvis::GenericGeometryTransferFunction<T>::createTexture() {
if (_shader == 0) {
initShader();
}
// acqiure a new TextureUnit, so that we don't mess with other currently bound textures during texture upload...
tgt::TextureUnit tfUnit;
tfUnit.activate();
......@@ -218,33 +246,20 @@ namespace campvis {
LGL_ERROR;
// render TF geometries into texture
glPushAttrib(GL_ALL_ATTRIB_BITS);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, _texture->getWidth(), _texture->getHeight());
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, 1, 0, 1, -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
_shader->activate();
_shader->setUniform("_projectionMatrix", tgt::mat4::createOrtho(0, 1, 0, 1, -1, 1));
LGL_ERROR;
for (typename std::vector<T*>::const_iterator it = _geometries.begin(); it != _geometries.end(); ++it) {
(*it)->render();
}
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
LGL_ERROR;
// deactivate FBO
// deactivate Shader and FBO
_shader->deactivate();
_fbo->deactivate();
LGL_ERROR;
......
......@@ -33,6 +33,8 @@
#include "tgt/texture.h"
#include "tgt/tgt_math.h"
#include "core/datastructures/facegeometry.h"
#include <algorithm>
namespace campvis {
......@@ -86,19 +88,20 @@ namespace campvis {
if (_keyPoints.size() < 2)
return;
glBegin(GL_QUADS);
std::vector<KeyPoint>::const_iterator a = _keyPoints.begin();
std::vector<KeyPoint>::const_iterator b = _keyPoints.begin()+1;
for (/* already inited */; b != _keyPoints.end(); ++a, ++b) {
glColor4ubv(a->_color.elem);
glVertex2f(a->_position, 0.f);
glVertex2f(a->_position, 1.f);
// TODO: regenerating these buffers each time is slow as hell
std::vector<tgt::vec3> vertices;
std::vector<tgt::vec4> colors;
glColor4ubv(b->_color.elem);
glVertex2f(b->_position, 1.f);
glVertex2f(b->_position, 0.f);
for (std::vector<KeyPoint>::const_iterator a = _keyPoints.begin(); a != _keyPoints.end(); ++a) {
vertices.push_back(tgt::vec3(a->_position, 0.f, 0.f));
vertices.push_back(tgt::vec3(a->_position, 1.f, 0.f));
colors.push_back(tgt::vec4(a->_color) / 255.f);
colors.push_back(tgt::vec4(a->_color) / 255.f);
}
glEnd();
FaceGeometry fg(vertices, vertices, colors);
fg.render(GL_TRIANGLE_STRIP);
}
TFGeometry1D* TFGeometry1D::createQuad(const tgt::vec2& interval, const tgt::col4& leftColor, const tgt::vec4& rightColor) {
tgtAssert(interval.x >= 0.f && interval.y <= 1.f, "Interval out of bounds");
......
// ================================================================================================
//
// 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 Universität München
// Boltzmannstr. 3, 85748 Garching b. München, 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.
//
// ================================================================================================
in vec4 ex_Color; ///< incoming color
out vec4 out_Color;
void main() {
out_Color = ex_Color;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment