Example #1
0
GLFormat::GLFormat(const QGLFormat & format)

:   m_majorVersion(format.majorVersion())
,   m_minorVersion(format.minorVersion())

,   m_redBufferSize  (format.redBufferSize())
,   m_greenBufferSize(format.greenBufferSize())
,   m_blueBufferSize (format.blueBufferSize())
,   m_alphaBufferSize(format.alpha() ? format.alphaBufferSize() : 0)

,   m_depthBufferSize  (format.depth()   ? format.depthBufferSize()   : 0)
,   m_stencilBufferSize(format.stencil() ? format.stencilBufferSize() : 0)

,   m_doubleBuffer(format.doubleBuffer())
,   m_stereo(format.stereo())

,   m_sampleBuffers(format.sampleBuffers())
,   m_samples(format.samples())

,   m_swapInterval(format.swapInterval())
{
  switch(format.profile())
    {
    default:
    case QGLFormat::NoProfile:
        m_profile = NoProfile; 
        break;
    case QGLFormat::CoreProfile:
        m_profile = CoreProfile; 
        break;
    case QGLFormat::CompatibilityProfile:
        m_profile = CompatibilityProfile; 
        break;
    };
}
Example #2
0
FLGLWidget::FLGLWidget(const QGLFormat& format, QWidget * parent) :
    QGLWidget(format, parent),
    m_vertexBuffer( QGLBuffer::VertexBuffer )
{
    QGLFormat glFormat = QGLWidget::format();
    qDebug() << QString( "OpenGL Version = %1, %2" )
    .arg( glFormat.majorVersion() )
    .arg( glFormat.minorVersion() );
    
    if ( !glFormat.sampleBuffers() )
        qWarning() << "Could not enable sample buffers";
    
    qDebug() << "OpenGL context valid =" << context()->isValid();

    logo = 0;
   xRot = 0;
   yRot = 0;
   zRot = 0;
}
Example #3
0
/*!
    Returns a window format for the OpenGL format specified by \a format.
*/
QSurfaceFormat QGLFormat::toSurfaceFormat(const QGLFormat &format)
{
    QSurfaceFormat retFormat;
    if (format.alpha())
        retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize());
    if (format.blueBufferSize() >= 0)
        retFormat.setBlueBufferSize(format.blueBufferSize());
    if (format.greenBufferSize() >= 0)
        retFormat.setGreenBufferSize(format.greenBufferSize());
    if (format.redBufferSize() >= 0)
        retFormat.setRedBufferSize(format.redBufferSize());
    if (format.depth())
        retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize());
    retFormat.setSwapBehavior(format.doubleBuffer() ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::DefaultSwapBehavior);
    if (format.sampleBuffers())
        retFormat.setSamples(format.samples() == -1 ? 4 : format.samples());
    if (format.stencil())
        retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize());
    retFormat.setStereo(format.stereo());
    retFormat.setMajorVersion(format.majorVersion());
    retFormat.setMinorVersion(format.minorVersion());
    retFormat.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>(format.profile()));
    return retFormat;
}
Example #4
0
MainWindow::MainWindow(QWidget * parent, FormBar * bar): QMainWindow(parent), m_formbar(bar) {
    setMenuBar(new QMenuBar(this));
    QMenu *fileMenu = menuBar() -> addMenu(tr("&File"));
    QAction *openAct = new QAction(tr("&Open"), this);
    openAct->setShortcuts(QKeySequence::Open);
    openAct->setStatusTip(tr("Open"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(openFile()));

    // Quit action
    QAction *quitAct = new QAction(tr("&Quit"), this);
    quitAct->setShortcuts(QKeySequence::Quit);
    quitAct->setStatusTip(tr("Quit"));
    connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));

    fileMenu->addAction(openAct);
    fileMenu->addAction(quitAct);

    QGLFormat glFormat;
    std::cout << glFormat.openGLVersionFlags() << std::endl;
    std::cout << (QGLFormat::OpenGL_Version_3_0 <= glFormat.openGLVersionFlags()) << std::endl;
    if(QGLFormat::OpenGL_Version_3_3 & glFormat.openGLVersionFlags())
    {
        glFormat.setVersion( 3,3 );
    }
    else
    {
        glFormat.setVersion( 2, 1 );
    }
    std::cout << "GL Version: " << glFormat.majorVersion() << " " << glFormat.minorVersion() << std::endl;
    glFormat.setProfile( QGLFormat::CompatibilityProfile );
    glFormat.setSampleBuffers( true );
    m_glwidget = new GLWidget(glFormat,this);
    connect(this,SIGNAL(meshLoaded(std::shared_ptr<const MeshPackage>)), m_glwidget,SLOT(receiveMesh(std::shared_ptr<const MeshPackage>)));
    connect(this,SIGNAL(formLoaded(const FormPackage &))
            , m_glwidget,SLOT(receiveForm(const FormPackage &)));
    setCentralWidget(m_glwidget);



    QDockWidget * dock = new QDockWidget(tr("Form Chooser"),this);
    if(!m_formbar) {
        m_formbar = new FormBar(this);
    }
    dock->setWidget(m_formbar);
    addDockWidget(Qt::LeftDockWidgetArea, dock);
    connect(this,SIGNAL(loadingNewMesh())
            , m_glwidget,SLOT(unloadMesh()));
    connect(this,SIGNAL(formLoaded(const FormPackage &))
            , m_formbar,SLOT(receiveForm(const FormPackage &)));
    connect(this,SIGNAL(particlesLoaded(std::shared_ptr<VertexBufferObject>))
            , m_glwidget,SLOT(receiveParticles(std::shared_ptr<VertexBufferObject>)));
    connect(
            m_formbar, SIGNAL(enableForm(const QString &)),
            m_glwidget, SLOT(enableForm(const QString &)));
    connect(
            m_formbar, SIGNAL(disableForm(const QString &)),
            m_glwidget, SLOT(disableForm(const QString &)));
    connect(
            m_formbar, SIGNAL(clearForms(void)),
            m_glwidget, SLOT(clearForms(void)));

}