コード例 #1
1
void Context::setupDebugLogging(QOpenGLContext *context) {
    QOpenGLDebugLogger *logger = new QOpenGLDebugLogger(context);
    QObject::connect(logger, &QOpenGLDebugLogger::messageLogged, nullptr, [](const QOpenGLDebugMessage& message){
        Context::debugMessageHandler(message);
    });
    if (logger->initialize()) {
        logger->enableMessages();
        logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
    } else {
        qCWarning(glLogging) <<  "OpenGL context does not support debugging";
    }
}
コード例 #2
0
void setupDebugLogger(QObject* window) {
    QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(window);
    logger->initialize(); // initializes in the current context, i.e. ctx
    logger->enableMessages();
    QObject::connect(logger, &QOpenGLDebugLogger::messageLogged, window, [&](const QOpenGLDebugMessage & debugMessage) {
        OpenGLDebug::log(debugMessage);
        
    });
}
コード例 #3
0
ファイル: main.cpp プロジェクト: MarcelEdward/hifi
    QTestWindow() {
        setSurfaceType(QSurface::OpenGLSurface);

        QSurfaceFormat format;
        // Qt Quick may need a depth and stencil buffer. Always make sure these are available.
        format.setDepthBufferSize(16);
        format.setStencilBufferSize(8);
        format.setVersion(4, 5);
        format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
        format.setOption(QSurfaceFormat::DebugContext);

        setFormat(format);

        _context = new QOpenGLContext;
        _context->setFormat(format);
        _context->create();

        show();
        makeCurrent();

        gpu::Context::init<gpu::GLBackend>();



        {
            QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
            logger->initialize(); // initializes in the current context, i.e. ctx
            logger->enableMessages();
            connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
                qDebug() << debugMessage;
            });
            //        logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
        }
        qDebug() << (const char*)glGetString(GL_VERSION);

        //_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
        //_textRenderer[1] = TextRenderer::getInstance(SERIF_FONT_FAMILY, 12, false,
        //    TextRenderer::SHADOW_EFFECT);
        //_textRenderer[2] = TextRenderer::getInstance(MONO_FONT_FAMILY, 48, -1,
        //    false, TextRenderer::OUTLINE_EFFECT);
        //_textRenderer[3] = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, 24);

        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glClearColor(0.2f, 0.2f, 0.2f, 1);
        glDisable(GL_DEPTH_TEST);

        makeCurrent();

        setFramePosition(QPoint(-1000, 0));
        resize(QSize(800, 600));
    }
コード例 #4
0
ファイル: window.cpp プロジェクト: giucam/trainsplanet
void Window::sync()
{
    QMutexLocker lock(&m_mutex);

    if (!m_terrain) {
        m_terrain = new Terrain;
        m_timer.start();

        QOpenGLDebugLogger *logger = new QOpenGLDebugLogger;
        logger->initialize();
        connect(logger, &QOpenGLDebugLogger::messageLogged, [](const QOpenGLDebugMessage &debugMessage) {
            qDebug() << debugMessage.message();
        });
        logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);

        m_terrain->init();

        qreal aspect = qreal(size().width()) / qreal(size().height());
        const qreal zNear = 1., zFar = 7000.0, fov = 60.0;
        m_projection.perspective(fov, aspect, zNear, zFar);

        m_camera.distance = 4800;
//         m_camera.orientation = QQuaternion(0.354394, -0.24355, 0.825291, -0.366037);
//         m_camera.rotation = QQuaternion(0.593273, 0.507288, 0.114765, -0.614423);
//         m_camera.rotation = QQuaternion(0, 0, 1, 45);

        glClearColor(1, 1, 1, 1);
    }

    if (m_generate) {
        m_terrain->generateMap(m_mapSeed);
        m_needsUpdate = true;
        m_generate = false;
    }

    updateView();

    m_frameTime = m_timer.restart();

    m_times[m_curTimeId] = m_frameTime;
    if (++m_curTimeId >= 20) {
        m_curTimeId = 0;
    }

    unsigned int totTime = 0;
    for (unsigned int t: m_times) {
        totTime += t;
    }
    m_fps = 20 * 1000. / (double)totTime;
}
コード例 #5
0
ファイル: main.cpp プロジェクト: DaveDubUK/hifi
    QTestWindow() {
        setSurfaceType(QSurface::OpenGLSurface);

        QSurfaceFormat format;
        // Qt Quick may need a depth and stencil buffer. Always make sure these are available.
        format.setDepthBufferSize(16);
        format.setStencilBufferSize(8);
        format.setVersion(4, 5);
        format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
        format.setOption(QSurfaceFormat::DebugContext);

        setFormat(format);

        _context = new QOpenGLContext;
        _context->setFormat(format);
        _context->create();

        show();
        makeCurrent();

        {
            QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
            logger->initialize(); // initializes in the current context, i.e. ctx
            logger->enableMessages();
            connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
                qDebug() << debugMessage;
            });
            //        logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
        }
        qDebug() << (const char*)glGetString(GL_VERSION);

#ifdef WIN32
        glewExperimental = true;
        GLenum err = glewInit();
        if (GLEW_OK != err) {
            /* Problem: glewInit failed, something is seriously wrong. */
            const GLubyte * errStr = glewGetErrorString(err);
            qDebug("Error: %s\n", errStr);
        }
        qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));

        if (wglewGetExtension("WGL_EXT_swap_control")) {
            int swapInterval = wglGetSwapIntervalEXT();
            qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
        }
        glGetError();
#endif

        _textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
        _textRenderer[1] = TextRenderer::getInstance(SERIF_FONT_FAMILY, 12, false,
            TextRenderer::SHADOW_EFFECT);
        _textRenderer[2] = TextRenderer::getInstance(MONO_FONT_FAMILY, 48, -1,
            false, TextRenderer::OUTLINE_EFFECT);
        _textRenderer[3] = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, 24);

        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glClearColor(0.2f, 0.2f, 0.2f, 1);
        glDisable(GL_DEPTH_TEST);

        makeCurrent();

        setFramePosition(QPoint(-1000, 0));
        resize(QSize(800, 600));
    }