The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated 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 cc2ab402 authored by schultezub's avatar schultezub
Browse files

started adapting client code and shaders to new OpenGL 3+ interface

 * introducing new TUMVis::QuadRenderer using VAO/VBOs
 * started upgrading shaders to GLSL 3.30


git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@271 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 0e27f529
......@@ -43,6 +43,7 @@
#include "application/tumvispainter.h"
#include "application/gui/mainwindow.h"
#include "core/tools/opengljobprocessor.h"
#include "core/tools/quadrenderer.h"
#include "core/pipeline/abstractpipeline.h"
#include "core/pipeline/visualizationpipeline.h"
#include "core/pipeline/pipelineevaluator.h"
......@@ -110,6 +111,8 @@ namespace TUMVis {
LERROR("Your system does not support GLSL Shader Version 1.30, which is mandatory. TUMVis will probably not work as intendet.");
}
QuadRenderer::init();
if (_useOpenCL) {
kisscl::CLRuntime::init();
}
......@@ -163,6 +166,8 @@ namespace TUMVis {
// deinit OpenGL and tgt
tgt::deinitGL();
QuadRenderer::deinit();
if (_useOpenCL) {
kisscl::CLRuntime::deinit();
}
......
......@@ -33,13 +33,14 @@
#include "tgt/qt/qtthreadedcanvas.h"
#include "tgt/qt/qtglcontext.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/quadrenderer.h"
#include "tgt/quadric.h"
#include "core/datastructures/imagedatarendertarget.h"
#include "core/pipeline/visualizationpipeline.h"
#include "core/tools/job.h"
#include "core/tools/opengljobprocessor.h"
#include "core/tools/quadrenderer.h"
namespace TUMVis {
const std::string TumVisPainter::loggerCat_ = "TUMVis.core.TumVisPainter";
......@@ -108,7 +109,9 @@ namespace TUMVis {
LGL_ERROR;
// execute the shader
tgt::QuadRenderer::renderQuad();
_copyShader->setAttributeLocation(0, "in_Position");
_copyShader->setAttributeLocation(1, "in_TexCoords");
QuadRdr.renderQuad();
_copyShader->deactivate();
LGL_ERROR;
}
......
......@@ -26,6 +26,9 @@
//
// ================================================================================================
#version 330
out vec4 out_Color;
#include "tools/texture2d.frag"
......@@ -36,6 +39,9 @@ uniform Texture2D _depthTexture;
void main() {
vec2 fragCoord = gl_FragCoord.xy * _viewportSizeRCP;
gl_FragData[0] = getElement2DNormalized(_colorTexture, fragCoord);
out_Color = getElement2DNormalized(_colorTexture, fragCoord);
gl_FragDepth = getElement2DNormalized(_depthTexture, fragCoord).z;
// gl_FragData[0] = getElement2DNormalized(_colorTexture, fragCoord);
// gl_FragDepth = getElement2DNormalized(_depthTexture, fragCoord).z;
}
// ================================================================================================
//
// This file is part of the TUMVis Visualization 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
//
// 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.
//
// ================================================================================================
void main() {
// just pass everything through to fragment shader.
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
gl_FrontColor = gl_Color;
}
\ No newline at end of file
......@@ -26,9 +26,14 @@
//
// ================================================================================================
#version 330
in vec3 in_Position;
in vec3 in_TexCoords;
out vec3 ex_TexCoords;
void main() {
// just pass everything through to fragment shader.
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
gl_FrontColor = gl_Color;
gl_Position = vec4(in_Position, 1.0);
ex_TexCoords = in_TexCoords;
}
......@@ -43,7 +43,7 @@ struct Texture2D {
vec4 getElement2D(in Texture2D tex, in vec2 texCoords) {
vec2 texCoordsNormalized = texCoords * tex._sizeRCP;
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoordsNormalized, 0.0, 1.0)).xy;
return texture2D(tex._texture, texCoordsNormalized);
return texture(tex._texture, texCoordsNormalized);
}
/**
......@@ -54,5 +54,5 @@ vec4 getElement2D(in Texture2D tex, in vec2 texCoords) {
*/
vec4 getElement2DNormalized(in Texture2D tex, in vec2 texCoords) {
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoords, 0.0, 1.0)).xy;
return texture2D(tex._texture, texCoords);
return texture(tex._texture, texCoords);
}
......@@ -46,7 +46,7 @@ struct Texture3D {
vec4 getElement3D(in Texture3D tex, in vec3 texCoords) {
vec3 texCoordsNormalized = texCoords * tex._sizeRCP;
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoordsNormalized, 0.0, 1.0)).xy;
return texture3D(tex._texture, texCoordsNormalized);
return texture(tex._texture, texCoordsNormalized);
}
/**
......@@ -57,5 +57,5 @@ vec4 getElement3D(in Texture3D tex, in vec3 texCoords) {
*/
vec4 getElement3DNormalized(in Texture3D tex, in vec3 texCoords) {
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoords, 0.0, 1.0)).xy;
return texture3D(tex._texture, texCoords);
return texture(tex._texture, texCoords);
}
......@@ -55,7 +55,7 @@ float mapIntensityToTFDomain(in TFParameters p, in float intensity) {
*/
vec4 lookupTF(in TFParameters p, in sampler1D tex, in float intensity) {
intensity = mapIntensityToTFDomain(p, intensity);
return texture1D(tex, intensity);
return texture(tex, intensity);
}
/**
......@@ -69,5 +69,5 @@ vec4 lookupTF(in TFParameters p, in sampler1D tex, in float intensity) {
*/
vec4 lookupTF(in TFParameters p, in sampler2D tex, in float intensity, in float y) {
intensity = mapIntensityToTFDomain(p, intensity);
return texture2D(tex, vec2(intensity, y));
return texture(tex, vec2(intensity, y));
}
......@@ -73,7 +73,7 @@ namespace TUMVis {
void RaycastingProcessor::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", _fragmentShaderFilename, "", false);
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough_deprecated.vert", _fragmentShaderFilename, "", false);
_shader->setHeaders(generateHeader());
_shader->rebuild();
}
......
#include "quadrenderer.h"
#include "core/datastructures/facegeometry.h"
namespace TUMVis {
QuadRenderer::QuadRenderer()
: tgt::Singleton<QuadRenderer>()
, _quad(0)
{
std::vector<tgt::vec3> vertices, texCorods;
vertices.push_back(tgt::vec3(-1.f, -1.f, 0.f));
vertices.push_back(tgt::vec3( 1.f, -1.f, 0.f));
vertices.push_back(tgt::vec3( 1.f, 1.f, 0.f));
vertices.push_back(tgt::vec3(-1.f, 1.f, 0.f));
texCorods.push_back(tgt::vec3(0.f, 0.f, 0.f));
texCorods.push_back(tgt::vec3(1.f, 0.f, 0.f));
texCorods.push_back(tgt::vec3(1.f, 1.f, 0.f));
texCorods.push_back(tgt::vec3(0.f, 1.f, 0.f));
_quad = new FaceGeometry(vertices, texCorods);
_quad->createGLBuffers();
}
QuadRenderer::~QuadRenderer() {
delete _quad;
}
void QuadRenderer::renderQuad() {
_quad->render();
// // TODO: get rid of intermediate mode and use VBOs as soon as they are ready.
// glDepthFunc(GL_ALWAYS);
// glBegin(GL_QUADS);
// glTexCoord2f(0.f, 0.f);
// glVertex2f(-1.f, -1.f);
//
// glTexCoord2f(1.f, 0.f);
// glVertex2f(1.f, -1.f);
//
// glTexCoord2f(1.f, 1.f);
// glVertex2f(1.f, 1.f);
//
// glTexCoord2f(0.f, 1.f);
// glVertex2f(-1.f, 1.f);
// glEnd();
// glDepthFunc(GL_LESS);
}
}
\ No newline at end of file
#ifndef QUADRENDERER_H__
#define QUADRENDERER_H__
#include "tgt/exception.h"
#include "tgt/singleton.h"
#include "tgt/tgt_gl.h"
namespace TUMVis {
class FaceGeometry;
/**
* Small helper singleton class for rendering the default [-1, 1]^2 quad.
*/
class QuadRenderer : public tgt::Singleton<QuadRenderer> {
friend class tgt::Singleton<QuadRenderer>;
public:
/**
*
*/
virtual ~QuadRenderer();
void renderQuad();
private:
QuadRenderer();
FaceGeometry* _quad;
};
#define QuadRdr tgt::Singleton<TUMVis::QuadRenderer>::getRef()
}
#endif // QUADRENDERER_H__
......@@ -28,7 +28,7 @@
#include "drrraycaster.h"
#include "tgt/quadrenderer.h"
#include "core/tools/quadrenderer.h"
#include "core/datastructures/imagedatarendertarget.h"
namespace TUMVis {
......@@ -63,7 +63,7 @@ namespace TUMVis {
else
glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
tgt::QuadRenderer::renderQuad();
QuadRdr.renderQuad();
LGL_ERROR;
rt->deactivate();
......
......@@ -60,7 +60,7 @@ namespace TUMVis {
void EEPGenerator::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/eepgenerator.frag", "", false);
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough_deprecated.vert", "modules/vis/eepgenerator.frag", "", false);
}
void EEPGenerator::deinit() {
......
......@@ -71,9 +71,9 @@ namespace TUMVis {
virtual void process(DataContainer& data);
GenericProperty<std::string> _sourceImageID; ///< image ID for input image
GenericProperty<std::string> _entryImageID; ///< image ID for output entry points image
GenericProperty<std::string> _exitImageID; ///< image ID for output exit points image
StringProperty _sourceImageID; ///< image ID for input image
StringProperty _entryImageID; ///< image ID for output entry points image
StringProperty _exitImageID; ///< image ID for output exit points image
CameraProperty _camera;
......
......@@ -28,7 +28,7 @@
#include "simpleraycaster.h"
#include "tgt/quadrenderer.h"
#include "core/tools/quadrenderer.h"
#include "core/datastructures/imagedatarendertarget.h"
namespace TUMVis {
......@@ -51,7 +51,7 @@ namespace TUMVis {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDepthFunc(GL_ALWAYS);
tgt::QuadRenderer::renderQuad();
QuadRdr.renderQuad();
LGL_ERROR;
rt->deactivate();
......
......@@ -28,7 +28,6 @@
#include "sliceextractor.h"
#include "tgt/logmanager.h"
#include "tgt/quadrenderer.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
......@@ -39,6 +38,8 @@
#include "core/classification/simpletransferfunction.h"
#include "core/tools/quadrenderer.h"
namespace TUMVis {
const std::string SliceExtractor::loggerCat_ = "TUMVis.modules.vis.SliceExtractor";
......@@ -88,7 +89,9 @@ namespace TUMVis {
rt->activate();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
tgt::QuadRenderer::renderQuad();
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoords");
QuadRdr.renderQuad();
rt->deactivate();
_shader->deactivate();
......
......@@ -26,6 +26,11 @@
//
// ================================================================================================
#version 330
in vec3 ex_TexCoords;
out vec4 out_Color;
#include "tools/texture2d.frag"
#include "tools/transferfunction.frag"
......@@ -35,6 +40,6 @@ uniform sampler1D _tfTex;
uniform TFParameters _tfTextureParameters;
void main() {
float intensity = getElement2DNormalized(_texture, gl_TexCoord[0].xy).a;
gl_FragData[0] = lookupTF(_tfTextureParameters, _tfTex, intensity);
float intensity = getElement2DNormalized(_texture, ex_TexCoords.xy).a;
out_Color = lookupTF(_tfTextureParameters, _tfTex, intensity);
}
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