Esempio n. 1
0
void QGLInfo::initialize()
{
    QWidget *win = qobject_cast<QGLWidget *>(parent());
    // We need some kind of GL context to do the querying.
    QGLWidget *glWidget = new QGLWidget(win);
    glWidget->makeCurrent();
    m_qtGLVersionInfo = reportQtGLVersionInfo();
    m_qtGLFeatures = reportQtGLFeatures();
    m_glVersionInfo = reportGLVersionInfo();
    m_glExtensionInfo = reportGLExtensionInfo();
    m_eglVersionInfo = reportEGLVersionInfo();
    m_eglExtensionInfo = reportEGLExtensionInfo();
    m_eglConfigInfo = reportEGLConfigInfo();
    glWidget->doneCurrent();
    delete glWidget;

    QString welcome;
    {
        QSettings freshStart;
        if (!freshStart.contains(QLatin1String("new_install")))
        {
            welcome = QLatin1String("<h1>Welcome to Qt3D!</h1>"
                                    "<p>Try running the FPS test from the "
                                    "View menu above to confirm that Qt3D "
                                    "is installed correctly.</p><hr>");
        }
        freshStart.setValue(QLatin1String("new_install"), true);
    }

    QString html = tr("<h1>Qt GL Info Report</h1>"
                      "<p>Generated at: %1</p>"
                      "<h2>Qt GL Version Info</h2>"
                      "<p>%2</p>"
                      "<h2>Qt GL Features</h2>"
                      "<p>%3</p>"
                      "<h2>GL Version Info</h2>"
                      "<p>%4</p>"
                      "<h2>GL Extension Info</h2>"
                      "<p>%5</p>")
            .arg(QDateTime::currentDateTime().toString())
            .arg(nice(m_qtGLVersionInfo))
            .arg(nice(m_qtGLFeatures))
            .arg(nice(m_glVersionInfo))
            .arg(nice(m_glExtensionInfo));
    if (!welcome.isEmpty())
        html.prepend(welcome);

#if !defined(QT_NO_EGL)
    html += tr("<h2>EGL Version Info</h2>"
               "<p>%1</p>"
               "<h2>EGL Extension Info</h2>"
               "<p>%2</p>"
               "<h2>EGL Configurations</h2>"
               "<p>%3</p>")
            .arg(nice(m_eglVersionInfo))
            .arg(nice(m_eglExtensionInfo))
            .arg(nice(m_eglConfigInfo));
#endif
    emit reportHtml(html);
}
Esempio n. 2
0
void QGLInfo::initialize()
{
    QWidget *win = qobject_cast<QGLWidget *>(parent());
    // We need some kind of GL context to do the querying.
    QGLWidget *glWidget = new QGLWidget(win);
    glWidget->makeCurrent();
    m_qtGLVersionInfo = reportQtGLVersionInfo();
    m_qtGLFeatures = reportQtGLFeatures();
    m_glVersionInfo = reportGLVersionInfo();
    m_glExtensionInfo = reportGLExtensionInfo();
    m_eglVersionInfo = reportEGLVersionInfo();
    m_eglExtensionInfo = reportEGLExtensionInfo();
    m_eglConfigInfo = reportEGLConfigInfo();
    glWidget->doneCurrent();
    delete glWidget;

    QString html = tr("<h1>Qt GL Info Report</h1>"
                      "<p>Generated at: %1</p>"
                      "<h2>Qt GL Version Info</h2>"
                      "<p>%2</p>"
                      "<h2>Qt GL Features</h2>"
                      "<p>%3</p>"
                      "<h2>GL Version Info</h2>"
                      "<p>%4</p>"
                      "<h2>GL Extension Info</h2>"
                      "<p>%5</p>")
            .arg(QDateTime::currentDateTime().toString())
            .arg(nice(m_qtGLVersionInfo))
            .arg(nice(m_qtGLFeatures))
            .arg(nice(m_glVersionInfo))
            .arg(nice(m_glExtensionInfo));
#if !defined(QT_NO_EGL)
    html += tr("<h2>EGL Version Info</h2>"
               "<p>%1</p>"
               "<h2>EGL Extension Info</h2>"
               "<p>%2</p>"
               "<h2>EGL Configurations</h2>"
               "<p>%3</p>")
            .arg(nice(m_eglVersionInfo))
            .arg(nice(m_eglExtensionInfo))
            .arg(nice(m_eglConfigInfo));
#endif
    emit reportHtml(html);
}
Esempio n. 3
0
/*!
  Overridden from QGLWidget to render the scenegraph
*/
void QuarterWidget::paintEvent(QPaintEvent* event)
{
    std::clock_t begin = std::clock();

    if(!initialized) {
        glEnable(GL_DEPTH_TEST);
        this->getSoRenderManager()->reinitialize();
        initialized = true;
    }

    getSoRenderManager()->activate();

    glEnable(GL_DEPTH_TEST);
    glMatrixMode(GL_PROJECTION);

    QGLWidget* w = static_cast<QGLWidget*>(this->viewport());
    assert(w->isValid() && "No valid GL context found!");
    // We might have to process the delay queue here since we don't know
    // if paintGL() is called from Qt, and we might have some sensors
    // waiting to trigger (the redraw sensor has a lower priority than a
    // normal field sensor to guarantee that your sensor is processed
    // before the next redraw). Disable autorendering while we do this
    // to avoid recursive redraws.

    // We set the PRIVATE(this)->processdelayqueue = false in redraw()
    // to avoid processing the delay queue when paintGL() is triggered
    // by us, and we don't want to process the delay queue in those
    // cases

    PRIVATE(this)->autoredrawenabled = false;

    if(PRIVATE(this)->processdelayqueue && SoDB::getSensorManager()->isDelaySensorPending()) {
        // processing the sensors might trigger a redraw in another
        // context. Release this context temporarily
        w->doneCurrent();
        SoDB::getSensorManager()->processDelayQueue(false);
        w->makeCurrent();
    }

    assert(w->isValid() && "No valid GL context found!");

    glDrawBuffer(w->doubleBuffer() ? GL_BACK : GL_FRONT);

    w->makeCurrent();
    this->actualRedraw();

    //start the standard graphics view processing for all widgets and graphic items. As 
    //QGraphicsView initaliizes a QPainter which changes the Opengl context in an unpredictable 
    //manner we need to store the context and recreate it after Qt is done.
    glPushAttrib(GL_MULTISAMPLE_BIT_EXT);
    inherited::paintEvent(event);
    glPopAttrib();

    if (w->doubleBuffer()) { w->swapBuffers(); }

    PRIVATE(this)->autoredrawenabled = true;

    // process the delay queue the next time we enter this function,
    // unless we get here after a call to redraw().
    PRIVATE(this)->processdelayqueue = true;

    std::clock_t end = std::clock();
    renderTime = double(double(end-begin)/CLOCKS_PER_SEC)*1000.0;
}