Commit e7e55015 authored by Jakob Weiss's avatar Jakob Weiss
Browse files

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

parent 17f5574c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -172,3 +172,8 @@ float getPhongShadingIntensity(in vec3 position, in LightSource light, in vec3 c
    #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);
}
+2 −2
Original line number Diff line number Diff line
@@ -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:
        void* targetThread = nullptr;
        volatile 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(targetThread);
        canvas->moveThreadAffinity(const_cast<void*>(targetThread));

        // reset the signal variable so that the new thread can continue.
        targetThread = nullptr;
+11 −0
Original line number Diff line number Diff line
@@ -40,6 +40,12 @@
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()
@@ -74,6 +80,11 @@ 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 {
+4 −0
Original line number Diff line number Diff line
@@ -230,6 +230,10 @@ 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.
+17 −2
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
 **********************************************************************/

#include "cgt/init.h"
#include "cgt/cgt_gl.h"

#include "cgt/assert.h"
#include "cgt/glcanvas.h"
@@ -102,11 +101,20 @@ 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();
@@ -132,4 +140,11 @@ 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

Loading