Ejemplo n.º 1
0
string glinfo::
        pretty_format(const QGLFormat& f)
{
    QGLFormat::OpenGLVersionFlags flag = f.openGLVersionFlags();

    stringstream s;
    s << "accum=" << f.accum() << endl
      << "accumBufferSize=" << f.accumBufferSize() << endl
      << "alpha=" << f.alpha() << endl
      << "alphaBufferSize=" << f.alphaBufferSize() << endl
      << "blueBufferSize=" << f.blueBufferSize() << endl
      << "depth=" << f.depth() << endl
      << "depthBufferSize=" << f.depthBufferSize() << endl
      << "directRendering=" << f.directRendering() << endl
      << "doubleBuffer=" << f.doubleBuffer() << endl
      << "greenBufferSize=" << f.greenBufferSize() << endl
      << "hasOverlay=" << f.hasOverlay() << endl
      << "redBufferSize=" << f.redBufferSize() << endl
      << "rgba=" << f.rgba() << endl
      << "sampleBuffers=" << f.sampleBuffers() << endl
      << "samples=" << f.samples() << endl
      << "stencil=" << f.stencil() << endl
      << "stencilBufferSize=" << f.stencilBufferSize() << endl
      << "stereo=" << f.stereo() << endl
      << "swapInterval=" << f.swapInterval() << endl
      << "" << endl
      << "hasOpenGL=" << f.hasOpenGL() << endl
      << "hasOpenGLOverlays=" << f.hasOpenGLOverlays() << endl
      << "OpenGL_Version_None=" << (QGLFormat::OpenGL_Version_None == flag) << endl
      << "OpenGL_Version_1_1=" << (QGLFormat::OpenGL_Version_1_1 & flag) << endl
      << "OpenGL_Version_1_2=" << (QGLFormat::OpenGL_Version_1_2 & flag) << endl
      << "OpenGL_Version_1_3=" << (QGLFormat::OpenGL_Version_1_3 & flag) << endl
      << "OpenGL_Version_1_4=" << (QGLFormat::OpenGL_Version_1_4 & flag) << endl
      << "OpenGL_Version_1_5=" << (QGLFormat::OpenGL_Version_1_5 & flag) << endl
      << "OpenGL_Version_2_0=" << (QGLFormat::OpenGL_Version_2_0 & flag) << endl
      << "OpenGL_Version_2_1=" << (QGLFormat::OpenGL_Version_2_1 & flag) << endl
      << "OpenGL_Version_3_0=" << (QGLFormat::OpenGL_Version_3_0 & flag) << endl
      << "OpenGL_ES_CommonLite_Version_1_0=" << (QGLFormat::OpenGL_ES_CommonLite_Version_1_0 & flag) << endl
      << "OpenGL_ES_Common_Version_1_0=" << (QGLFormat::OpenGL_ES_Common_Version_1_0 & flag) << endl
      << "OpenGL_ES_CommonLite_Version_1_1=" << (QGLFormat::OpenGL_ES_CommonLite_Version_1_1 & flag) << endl
      << "OpenGL_ES_Common_Version_1_1=" << (QGLFormat::OpenGL_ES_Common_Version_1_1 & flag) << endl
      << "OpenGL_ES_Version_2_0=" << (QGLFormat::OpenGL_ES_Version_2_0 & flag) << endl;

    return s.str();
}
Ejemplo n.º 2
0
MythRenderOpenGL* MythRenderOpenGL::Create(const QString &painter,
                                           QPaintDevice* device)
{
#ifdef USE_OPENGL_QT5
    MythRenderFormat format = QSurfaceFormat::defaultFormat();
    format.setDepthBufferSize(0);
    format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
# ifdef USING_OPENGLES
    format.setRenderableType(QSurfaceFormat::OpenGLES);
# endif
#else
    MythRenderFormat format = QGLFormat(QGL::NoDepthBuffer);
#endif

    bool setswapinterval = false;
    int synctovblank = -1;

#ifdef USING_X11
    synctovblank = CheckNVOpenGLSyncToVBlank();
#endif

    if (synctovblank < 0)
    {
        LOG(VB_GENERAL, LOG_WARNING, LOC + "Could not determine whether Sync "
                                           "to VBlank is enabled.");
    }
    else if (synctovblank == 0)
    {
        // currently only Linux NVidia is supported and there is no way of
        // forcing sync to vblank after the app has started. util-nvctrl will
        // warn the user and offer advice on settings.
    }
    else
    {
        LOG(VB_GENERAL, LOG_INFO, LOC + "Sync to VBlank is enabled (good!)");
    }

#if defined(Q_OS_MAC)
    LOG(VB_GENERAL, LOG_INFO, LOC + "Forcing swap interval for OS X.");
    setswapinterval = true;
#endif

    if (setswapinterval)
        format.setSwapInterval(1);

#if ANDROID
    int openGLVersionFlags = QGLFormat::OpenGL_ES_Version_2_0;
    LOG(VB_GENERAL, LOG_INFO, "OpenGL ES2 forced for Android");
#elif defined USE_OPENGL_QT5 && defined USING_OPENGLES
    int openGLVersionFlags = QGLFormat::OpenGL_ES_Version_2_0;
#else
    // Check OpenGL version supported
    QGLWidget *dummy = new QGLWidget;
    dummy->makeCurrent();
    QGLFormat qglFormat = dummy->format();
    int openGLVersionFlags = qglFormat.openGLVersionFlags();
    delete dummy;
#endif

#ifdef USING_OPENGLES
    if (!(openGLVersionFlags & QGLFormat::OpenGL_ES_Version_2_0))
    {
        LOG(VB_GENERAL, LOG_WARNING,
            "Using OpenGL ES 2.0 render, however OpenGL ES 2.0 "
            "version not supported");
    }
    if (device)
        return new MythRenderOpenGL2ES(format, device);
    return new MythRenderOpenGL2ES(format);
#else
    if ((openGLVersionFlags & QGLFormat::OpenGL_Version_2_0) &&
        (painter.contains(OPENGL2_PAINTER) || painter.contains(AUTO_PAINTER) ||
         painter.isEmpty()))
    {
        LOG(VB_GENERAL, LOG_INFO, "Trying the OpenGL 2.0 render");
        format.setVersion(2,0);
        if (device)
            return new MythRenderOpenGL2(format, device);
        return new MythRenderOpenGL2(format);
    }

    if (!(openGLVersionFlags & QGLFormat::OpenGL_Version_1_2))
    {
        LOG(VB_GENERAL, LOG_WARNING, "OpenGL 1.2 not supported, get new hardware!");
        return NULL;
    }

    LOG(VB_GENERAL, LOG_INFO, "Trying the OpenGL 1.2 render");
    format.setVersion(1,3);
    if (device)
        return new MythRenderOpenGL1(format, device);
    return new MythRenderOpenGL1(format);

#endif
}
Ejemplo n.º 3
0
/*
========================
getDriverInfoString

 fills the GL info widget with text
========================
*/
QString CGLWidget::getDriverInfoString( void ) const
{
	// the context must be valied!
	if( !context()->isValid() )
		return QString( "<invalid OpenGL context>" );

	// read OpenGL infos
	QString text;
	text += tr( "Vendor:   %1\n" ).arg( (const char*)glGetString( GL_VENDOR ) );
	text += tr( "Renderer: %1\n" ).arg( (const char*)glGetString( GL_RENDERER ) );
	text += tr( "Version:  %1\n" ).arg( (const char*)glGetString( GL_VERSION ) );
	text += tr( "\n" );

	// print framebuffer format
	QGLFormat fmt = context()->format();
	text += tr( "Framebuffer Format:\n" );
	text += tr( " RGBA bits:    (%1,%2,%3,%4)\n" ).
				arg( fmt.redBufferSize() ).
				arg( fmt.greenBufferSize() ).
				arg( fmt.blueBufferSize() ).
				arg( fmt.alphaBufferSize() );
	text += tr( " Depth bits:   %1\n" ).arg( fmt.depthBufferSize() );
	text += tr( " Stencil bits: %1\n" ).arg( fmt.stencilBufferSize() );
	text += tr( "\n" );

	// shading language version
	if( fmt.openGLVersionFlags() & fmt.OpenGL_Version_2_0 )
	{
		QString version( (const char*)glGetString( GL_SHADING_LANGUAGE_VERSION ) );
		text += QString( "Shading Language Version: %1\n" ).arg( version );
	}

	// check for geometry shader
	bool hasGeoShader = false;
#ifdef CONFIG_ENABLE_GEOMETRY_SHADER
	hasGeoShader = ( NULL != strstr( (const char*)glGetString( GL_EXTENSIONS ), "GL_EXT_geometry_shader4" ) );
	if( hasGeoShader )
	{
		text += tr( "GL_EXT_geometry_shader4 available\n" );
	}
	else
	{
		text += tr( "GL_EXT_geometry_shader4 not supported\n" );
	}
#endif
	text += tr( "\n" );

	GLint i;
#define PRINT_CONSTANT(Name) \
	glGetIntegerv( Name, &i ); \
	text += tr( #Name " = %1\n" ).arg( i );

	PRINT_CONSTANT( GL_MAX_TEXTURE_SIZE );
	PRINT_CONSTANT( GL_MAX_TEXTURE_UNITS );
	PRINT_CONSTANT( GL_MAX_VERTEX_ATTRIBS );
	PRINT_CONSTANT( GL_MAX_VERTEX_UNIFORM_COMPONENTS );
	PRINT_CONSTANT( GL_MAX_VARYING_FLOATS ); // alias for GL_MAX_VARYING_COMPONENTS_EXT
	PRINT_CONSTANT( GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS );
	PRINT_CONSTANT( GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS );
	PRINT_CONSTANT( GL_MAX_TEXTURE_IMAGE_UNITS );
	PRINT_CONSTANT( GL_MAX_TEXTURE_COORDS );
	PRINT_CONSTANT( GL_MAX_FRAGMENT_UNIFORM_COMPONENTS );

	if( hasGeoShader )
	{
		PRINT_CONSTANT( GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT );
		PRINT_CONSTANT( GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT );
		PRINT_CONSTANT( GL_MAX_VERTEX_VARYING_COMPONENTS_EXT );
		PRINT_CONSTANT( GL_MAX_VARYING_COMPONENTS_EXT );
		PRINT_CONSTANT( GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT) ;
		PRINT_CONSTANT( GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT );
		PRINT_CONSTANT( GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT );
	}

#undef PRINT_CONSTANT

	return text;
}
Ejemplo n.º 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)));

}