Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit e835e6f7 authored by Jakob Weiss's avatar Jakob Weiss

Revert "First steps replacing QGLWidget with QOpenGLWidget - currently crashes and burns horribly"

This reverts commit e7e55015.

# Conflicts:
#	core/glsl/tools/shading.frag
parent c662c17e
......@@ -171,21 +171,4 @@ float getPhongShadingIntensity(in vec3 position, in LightSource light, in vec3 c
toReturn *= computeAttenuation(light._attenuation, d);
#endif
return (toReturn.x + toReturn.y + toReturn.z) / 3.0;
}
vec3 calculateContourShading(in vec3 position, in vec3 camera, in vec3 normal, in vec3 materialColor, in vec3 outlineColor, in float contourExponent) {
float outlineStrength = 1. - pow(clamp(-dot(normalize(normal), normalize(position - camera)), 0, 1), contourExponent);
return mix(materialColor, outlineColor, outlineStrength);
}
vec4 calculateContourShading2(in vec3 position, in vec3 camera, in vec3 normal, in vec4 materialColor, in vec4 outlineColor, in float contourExponent) {
float outlineStrength = 1. - pow(clamp(dot(normal, normalize(camera - position)), 0, 1), contourExponent);
return outlineStrength * outlineColor;
}
void blendUnder(inout vec4 colorAbove, in vec4 colorBelow)
{
colorAbove.rgb = colorAbove.rgb + colorBelow.rgb * colorBelow.a * (1.0 - colorAbove.a);
colorAbove.a = colorAbove.a + (1.0 -colorAbove.a) * colorBelow.a;
}
}
\ No newline at end of file
......@@ -99,7 +99,7 @@ namespace campvis {
CAMPVIS_CORE_API void startOpenGlThreadAndMoveQtThreadAffinity(cgt::Runnable* runnable, cgt::GLCanvas* canvas) {
// welcome to a complex signalling ping-pong to move the OpenGL context thread affinity
// we will use targetThread as signalling variable and initialize it with nullptr:
volatile void* targetThread = nullptr;
void* targetThread = nullptr;
// start the new thread with special init function
runnable->start([&]() {
......@@ -120,7 +120,7 @@ namespace campvis {
std::this_thread::yield();
// set the QGLContext's thread affinity
canvas->moveThreadAffinity(const_cast<void*>(targetThread));
canvas->moveThreadAffinity(targetThread);
// reset the signal variable so that the new thread can continue.
targetThread = nullptr;
......
......@@ -40,12 +40,6 @@
namespace campvis {
const std::string AbstractPipeline::loggerCat_ = "CAMPVis.core.datastructures.AbstractPipeline";
void AbstractPipeline::debugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * message, const void * userParam)
{
std::cerr << "**** GL Debug Message Error: " << type << " " << id << " " << severity << " " << std::endl << message << std::endl;
}
AbstractPipeline::AbstractPipeline(DataContainer& dc)
: HasPropertyCollection()
, cgt::EventHandler()
......@@ -80,11 +74,6 @@ namespace campvis {
_painter->init();
initAllProperties();
glDebugMessageCallback(&debugMessageCallback, this);
LGL_ERROR;
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, true);
LGL_ERROR;
// initialize all processors:
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
try {
......
......@@ -230,10 +230,6 @@ namespace campvis {
sigslot::signal0 s_deinit;
protected:
/// debug message callback registered to glDebugMessageCallback to catch OpenGL Errors
static void debugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam);
/**
* Forces the execution of the given processor regardless of its invalidation or enabled state.
* \param processor Processor to execute.
......
......@@ -27,6 +27,7 @@
**********************************************************************/
#include "cgt/init.h"
#include "cgt/cgt_gl.h"
#include "cgt/assert.h"
#include "cgt/glcanvas.h"
......@@ -101,20 +102,11 @@ void initGL(GLCanvas* backgroundGlContext, InitFeature::Features featureset) {
TextureManager::init();
if (featureset & InitFeature::GPU_PROPERTIES) {
if (featureset & InitFeature::GPU_PROPERTIES )
GpuCapabilities::init();
#ifdef _MSC_VER
GpuCapabilitiesWindows::init();
#endif
}
// setup debug callback
if (featureset & InitFeature::GL_DEBUG_CALLBACK) {
glDebugMessageCallback(&debugMessageCallback, nullptr);
LGL_ERROR;
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, true);
LGL_ERROR;
}
// starting shadermanager
ShaderManager::init();
......@@ -140,11 +132,4 @@ void deinitGL() {
}
void debugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * message, const void * userParam)
{
std::cerr << "**** GL Debug Message Error: " << type << " " << id << " " << severity << " " << std::endl << message << std::endl;
}
} // namespace
......@@ -32,28 +32,25 @@
#include "cgt/types.h"
#include "cgt/logmanager.h"
#include "cgt/cgt_gl.h"
namespace cgt {
class GLCanvas;
class CGT_API InitFeature {
public:
enum Features {
NONE = 0,
LOG_MANAGER = 1 << 0,
FILE_SYSTEM = 1 << 1,
GPU_PROPERTIES = 1 << 2,
SCRIPT_MANAGER = 1 << 3,
SHADER_MANAGER = 1 << 4,
TEXTURE_MANAGER = 1 << 6,
TESSELATOR = 1 << 7,
GL_DEBUG_CALLBACK = 1 << 8,
LOG_TO_CONSOLE = 1 << 30,
ALL = (
NONE = 0,
LOG_MANAGER = 1 << 0,
FILE_SYSTEM = 1 << 1,
GPU_PROPERTIES = 1 << 2,
SCRIPT_MANAGER = 1 << 3,
SHADER_MANAGER = 1 << 4,
TEXTURE_MANAGER = 1 << 6,
TESSELATOR = 1 << 7,
LOG_TO_CONSOLE = 1 << 30,
ALL = (
LOG_MANAGER | FILE_SYSTEM | GPU_PROPERTIES |
SCRIPT_MANAGER | SHADER_MANAGER |
TEXTURE_MANAGER | TESSELATOR | GL_DEBUG_CALLBACK |
TEXTURE_MANAGER | TESSELATOR |
LOG_TO_CONSOLE
)
};
......@@ -69,11 +66,7 @@ CGT_API void initGL(GLCanvas* backgroundGlContext, InitFeature::Features feature
CGT_API void deinit();
/// deinit the singletons of cgt
CGT_API void deinitGL();
/// debug message callback registered to glDebugMessageCallback to catch OpenGL Errors
void debugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam);
};
#endif //CGT_INIT_H
......@@ -29,18 +29,17 @@
#include "qtcanvas.h"
#include <QThread>
#include <QOpenGLContext>
namespace cgt {
// shared context widget
QOpenGLWidget* QtCanvas::shareWidget_ = 0;
QGLWidget* QtCanvas::shareWidget_ = 0;
QtCanvas::QtCanvas(const std::string& title,
const ivec2& size,
const Buffers buffers,
QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name*/)
: QOpenGLWidget(parent, f)
: QGLWidget(getQGLFormat(buffers), 0, (shared ? shareWidget_ : 0), f)
, GLCanvas(title, size, buffers)
{
resize(size.x, size.y);
......@@ -53,7 +52,7 @@ QtCanvas::QtCanvas(const std::string& title,
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// we have our own AutoBufferSwap-mechanism (GLCanvas::setAutoFlush), so disable the one of qt
//setAutoBufferSwap(false); // TODO jw: not sure what this does, figure out later
setAutoBufferSwap(false);
rgbaSize_ = ivec4(format().redBufferSize(),
format().greenBufferSize(),
......@@ -61,7 +60,7 @@ QtCanvas::QtCanvas(const std::string& title,
format().alphaBufferSize());
stencilSize_ = format().stencilBufferSize();
depthSize_ = format().depthBufferSize();
doubleBuffered_ = format().swapBehavior() == QSurfaceFormat::DoubleBuffer;
doubleBuffered_ = doubleBuffer();
stereoViewing_ = format().stereo();
connect(this, &QtCanvas::s_sizeChangedExternally, this, &QtCanvas::sizeChangedExternally);
......@@ -69,13 +68,13 @@ QtCanvas::QtCanvas(const std::string& title,
}
QtCanvas::QtCanvas(QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name*/)
: QOpenGLWidget(parent, f)
: QGLWidget(getQGLFormat(), 0, (shared ? shareWidget_ : 0), f)
{
if (shared && shareWidget_ == 0)
shareWidget_ = this;
// we have our own AutoBufferSwap-mechanism (GLCanvas::setAutoFlush), so disable the one of qt
//setAutoBufferSwap(false);
setAutoBufferSwap(false);
rgbaSize_ = ivec4(format().redBufferSize(),
format().greenBufferSize(),
......@@ -83,7 +82,7 @@ QtCanvas::QtCanvas(QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name
format().alphaBufferSize());
stencilSize_ = format().stencilBufferSize();
depthSize_ = format().depthBufferSize();
doubleBuffered_ = format().swapBehavior() == QSurfaceFormat::DoubleBuffer;
doubleBuffered_ = doubleBuffer();
stereoViewing_ = format().stereo();
}
......@@ -91,7 +90,7 @@ QtCanvas::~QtCanvas() {}
void QtCanvas::moveThreadAffinity(void* threadPointer) {
QThread* qThreadPointer = static_cast<QThread*>(threadPointer);
context()->moveToThread(qThreadPointer);
this->context()->moveToThread(qThreadPointer);
}
void* QtCanvas::getCurrentThreadPointer() {
......@@ -110,17 +109,16 @@ void QtCanvas::paintGL() {
}
void QtCanvas::repaint() {
QOpenGLWidget::update();
updateGL();
}
void QtCanvas::update() {
QOpenGLWidget::update();
QWidget::update();
}
void QtCanvas::swap() {
//context()->swapBuffers();
//QOpenGLWidget::makeCurrent();
update();
QGLWidget::swapBuffers();
QGLWidget::makeCurrent();
}
void QtCanvas::toggleFullScreen() {
......@@ -257,37 +255,25 @@ cgt::Event::Modifier QtCanvas::getModifier(QInputEvent* e) {
return cgt::Event::Modifier(result);
}
QSurfaceFormat QtCanvas::getQGLSurfaceFormat(const Buffers buffers) {
QSurfaceFormat format = getQGLSurfaceFormat();
if (buffers & GLCanvas::ALPHA_BUFFER) format.setAlphaBufferSize(8);
if (buffers & GLCanvas::DEPTH_BUFFER) format.setDepthBufferSize(24);
if (buffers & GLCanvas::DOUBLE_BUFFER) format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
if (buffers & GLCanvas::STENCIL_BUFFER) format.setStencilBufferSize(8);
if (buffers & GLCanvas::ACCUM_BUFFER) {// TODO QSurfaceFormat does not support htis anymore?
throw std::logic_error("Accumulation buffer not implemented directly on the surface.");
}
if (buffers & GLCanvas::STEREO_VIEWING) {
format.setOption(QSurfaceFormat::StereoBuffers);
}
if (buffers & GLCanvas::MULTISAMPLING) {
format.setSamples(2);
}
QGLFormat QtCanvas::getQGLFormat(const Buffers buffers) {
QGLFormat format = getQGLFormat();
format.setAlpha(buffers & GLCanvas::ALPHA_BUFFER);
format.setDepth(buffers & GLCanvas::DEPTH_BUFFER);
format.setDoubleBuffer(buffers & GLCanvas::DOUBLE_BUFFER);
format.setStencil(buffers & GLCanvas::STENCIL_BUFFER);
format.setAccum(buffers & GLCanvas::ACCUM_BUFFER);
format.setStereo(buffers & GLCanvas::STEREO_VIEWING);
format.setSampleBuffers(buffers & GLCanvas::MULTISAMPLING);
return format;
}
QSurfaceFormat QtCanvas::getQGLSurfaceFormat()
QGLFormat QtCanvas::getQGLFormat()
{
QSurfaceFormat format;
format.setVersion(4, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
//QSurfaceFormat::setDefaultFormat(format);
QGLFormat format = QGLFormat(QGL::NoDeprecatedFunctions);
format = QGLFormat(QGL::NoDeprecatedFunctions);
format.setProfile(QGLFormat::CoreProfile);
//format.setVersion(3, 3);
return format;
}
......@@ -621,11 +607,11 @@ QSize QtCanvas::sizeHint() const {
}
void QtCanvas::acquireAsCurrentContext() {
QOpenGLWidget::makeCurrent();
QGLWidget::makeCurrent();
}
void QtCanvas::releaseAsCurrentContext() {
QOpenGLWidget::doneCurrent();
QGLWidget::doneCurrent();
}
void QtCanvas::sizeChangedExternally(int w, int h) {
......
......@@ -32,7 +32,7 @@
#include "cgt/glcanvas.h"
#include "cgt/types.h"
#include <QOpenGLWidget>
#include <QGLWidget>
#include <QGLFormat>
#include <QMouseEvent>
#include <QKeyEvent>
......@@ -44,7 +44,7 @@ namespace cgt {
/**
* Qt implementation of GLCanvas. Inherits QGLWidget and combines the Qt methods and cgt methods.
*/
class CGT_API QtCanvas : public QOpenGLWidget, public GLCanvas {
class CGT_API QtCanvas : public QGLWidget, public GLCanvas {
Q_OBJECT;
public:
......@@ -150,8 +150,8 @@ public:
static cgt::MouseEvent::MouseButtons getButtons(QMouseEvent* e);
static cgt::Event::Modifier getModifier(QInputEvent* e);
static KeyEvent::KeyCode getKey(int key);
static QSurfaceFormat getQGLSurfaceFormat(const Buffers buffers);
static QSurfaceFormat getQGLSurfaceFormat();
static QGLFormat getQGLFormat(const Buffers buffers);
static QGLFormat getQGLFormat();
signals:
void s_sizeChangedExternally(int w, int h);
......@@ -161,8 +161,7 @@ protected slots:
void changeFullScreen(bool fullscreen);
protected:
static QOpenGLWidget* shareWidget_; ///< widget that this canvas shares the OpenGL context with
///< TODO: This is very bad design. Context sharing should happen on another level and not using a static
static QGLWidget* shareWidget_; ///< widget that this canvas shares the OpenGL context with
signals:
void fullScreenChanged(bool fullscreen);
......
......@@ -41,8 +41,8 @@ uniform float _lambda;
uniform float _minDepth;
uniform float _maxDepth;
uniform vec4 _coldColor;
uniform vec4 _warmColor;
uniform vec3 _coldColor;
uniform vec3 _warmColor;
int _halfKernelDimension;
float[25] _gaussKernel;
......@@ -116,10 +116,10 @@ void main() {
#ifdef USE_COLORCODING
float deltaDPlus = (deltaD > 0 ? deltaD : 0.0);
float deltaDMinus = (deltaD < 0 ? -deltaD : 0.0);
curColor.rgb += (_coldColor.rgb * _coldColor.a * deltaDMinus + _warmColor.rgb * _warmColor.a * deltaDPlus) * _lambda;
curColor.rgb += (_coldColor * deltaDMinus + _warmColor * deltaDPlus) * _lambda;
#else
if (deltaD < 0.0) {
curColor.rgb += deltaD * _lambda * _warmColor.rgb;
curColor.rgb += deltaD * _lambda;
}
#endif
......
......@@ -46,8 +46,8 @@ namespace campvis {
, p_sigma("Sigma", "Sigma of Gaussian Filter", 2.f, 0.f, 10.f, 0.1f)
, p_lambda("Lambda", "Strength of Depth Darkening Effect", 10.f, 0.f, 150.f, 0.1f)
, p_useColorCoding("UseColorCoding", "Cold/Warm Color Coding", false)
, p_coldColor("ColdColor", "Cold Color (Far Objects)", cgt::vec4(0.f, 0.f, 1.f, 1.0f))
, p_warmColor("WarmColor", "Warm Color (Near Objects)", cgt::vec4(1.f, 0.f, 0.f, 1.0f))
, p_coldColor("ColdColor", "Cold Color (Far Objects)", cgt::vec3(0.f, 0.f, 1.f), cgt::vec3(0.f), cgt::vec3(1.f))
, p_warmColor("WarmColor", "Warm Color (Near Objects)", cgt::vec3(1.f, 0.f, 0.f), cgt::vec3(0.f), cgt::vec3(1.f))
, _shader(0)
, _glReduction(0)
{
......@@ -100,9 +100,9 @@ namespace campvis {
_shader->setUniform("_lambda", p_lambda.getValue());
_shader->setUniform("_minDepth", minDepth);
_shader->setUniform("_maxDepth", maxDepth);
_shader->setUniform("_warmColor", p_warmColor.getValue());
if (p_useColorCoding.getValue()) {
_shader->setUniform("_coldColor", p_coldColor.getValue());
_shader->setUniform("_warmColor", p_warmColor.getValue());
}
createAndAttachColorTexture();
......
......@@ -30,7 +30,6 @@
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/floatingpointproperty.h"
#include "core/properties/colorproperty.h"
#include "modules/modulesapi.h"
......@@ -62,7 +61,7 @@ namespace campvis {
/// \see AbstractProcessor::deinit
virtual void deinit();
/// To be used in ProcessorFactory static methods
static const std::string getId() { return "DepthDarkening"; };
/// \see AbstractProcessor::getName()
......@@ -81,8 +80,8 @@ namespace campvis {
FloatProperty p_lambda; ///< strength of depth effect
BoolProperty p_useColorCoding; ///< Flag whether to use depth color coding
ColorProperty p_coldColor; ///< Cold color (color for far objects)
ColorProperty p_warmColor; ///< Warm color (color for near objects)
Vec3Property p_coldColor; ///< Cold color (color for far objects)
Vec3Property p_warmColor; ///< Warm color (color for near objects)
protected:
/// \see AbstractProcessor::updateResult
......
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