Esempio n. 1
0
FMSampleTextView::FMSampleTextView ( QWidget* parent )
		: QGraphicsView ( parent ),
		hasPendingUpdate ( false )
{
#if 0
	QGLFormat glfmt;
	glfmt.setSampleBuffers ( true );
	QGLWidget *glwgt = new QGLWidget ( glfmt );
// 	qDebug()<<"GL:: A DR S"<<glwgt->format().alpha()<<glwgt->format().directRendering()<<glwgt->format().sampleBuffers();
// 	setViewport(glwgt);
	if ( glwgt->format().sampleBuffers() )
	{
		setViewport ( glwgt );
		qDebug() <<"opengl enabled - DirectRendering("<< glwgt->format().directRendering() <<") - SampleBuffers("<< glwgt->format().sampleBuffers() <<")";
	}
	else
	{
		qDebug() <<"opengl disabled - DirectRendering("<< glwgt->format().directRendering() <<") - SampleBuffers("<< glwgt->format().sampleBuffers() <<")";
		delete glwgt;
	}
#endif

	setInteractive ( false );
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	theRect = 0;
	fPage = 0;
	isSelecting = false;
	isPanning = false;
	setAlignment ( Qt::AlignTop | Qt::AlignHCenter );
	setTransformationAnchor ( QGraphicsView::NoAnchor );
	setRenderHint ( QPainter::Antialiasing, true );
	setBackgroundBrush(Qt::white);
}
Esempio n. 2
0
void PhotoKitView::setRenderingSystem()
{
	QWidget *viewport = 0;

#ifndef QT_NO_OPENGL
	if (Config::openGlRendering) {
        setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
		QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers));
		if (Config::noScreenSync)
			glw->format().setSwapInterval(0);
		glw->setAutoFillBackground(false);
		viewport = glw;
		setCacheMode(QGraphicsView::CacheNone);
		if (Config::verbose)
			ezlog_debug("- using OpenGL");
	} else // software rendering
#endif
	{
		// software rendering
        setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
		viewport = new QWidget;
		setCacheMode(QGraphicsView::CacheBackground);
		if (Config::verbose)
			ezlog_debug("- using software rendering");
	}

	setViewport(viewport);
}
Esempio n. 3
0
void MainWindow::setRenderingSystem()
{
    QWidget *viewport = 0;

#ifndef QT_NO_OPENGL
    if (Colors::openGlRendering) {
        QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers));
        if (Colors::noScreenSync)
            glw->format().setSwapInterval(0);
        glw->setAutoFillBackground(false);
        viewport = glw;
        setCacheMode(QGraphicsView::CacheNone);
        if (Colors::verbose)
            qDebug() << "- using OpenGL";
    } else // software rendering
#endif
    {
        // software rendering
        viewport = new QWidget;
        setCacheMode(QGraphicsView::CacheBackground);
        if (Colors::verbose)
            qDebug() << "- using software rendering";
    }

    setViewport(viewport);
}
Esempio n. 4
0
bool video_output_qt::supports_stereo() const
{
    QGLFormat fmt = _format;
    fmt.setStereo(true);
    QGLWidget *tmpwidget = new QGLWidget(fmt);
    bool ret = tmpwidget->format().stereo();
    delete tmpwidget;
    return ret;
}
Esempio n. 5
0
string glinfo::
        pretty_format(const QGLWidget& w)
{
    stringstream s;

    s << "doubleBuffer=" <<  w.doubleBuffer() << endl
      << "isSharing=" <<  w.isSharing() << endl
      << "isValid=" <<  w.isValid() << endl
      << pretty_format( w.format() );

    return s.str();
}
Esempio n. 6
0
void Colors::detectSystemResources()
{
#ifndef QT_NO_OPENGL
    if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
        Colors::glVersion = "2.0 or higher";
    else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_5)
        Colors::glVersion = "1.5";
    else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_4)
        Colors::glVersion = "1.4";
    else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_3)
        Colors::glVersion = "1.3 or lower";
    if (Colors::verbose)
        qDebug() << "- OpenGL version:" << Colors::glVersion;

    QGLWidget glw;
    if (!QGLFormat::hasOpenGL()
        || !glw.format().directRendering()
        || !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_5)
        || glw.depth() < 24
    )
#else
    if (Colors::verbose)
        qDebug() << "- OpenGL not supported by current build of Qt";
#endif
    {
        Colors::openGlAwailable = false;
        if (Colors::verbose)
            qDebug("- OpenGL not recommended on this system");
    }

#if defined(Q_WS_WIN)
    Colors::direct3dAwailable = false; // for now.
#endif

#if defined(Q_WS_X11)
    // check if X render is present:
    QPixmap tmp(1, 1);
    if (!tmp.x11PictureHandle() && tmp.paintEngine()->type() == QPaintEngine::X11){
        Colors::xRenderPresent = false;
        if (Colors::verbose)
            qDebug("- X render not present");
    }

#endif

    QWidget w;
    if (Colors::verbose)
        qDebug() << "- Color depth: " << QString::number(w.depth());
}
Esempio n. 7
0
void glinfo::
        test()
{
    // It should provide a human readable text string of a Qt managed open gl render context.
    {
        std::string name = "glinfo";
        int argc = 1;
        char * argv = &name[0];
        QApplication a(argc,&argv); // takes 0.4 s if this is the first instantiation of QApplication
        QGLWidget w;
        w.makeCurrent ();

        string ws = glinfo::pretty_format (w);
        string fs = glinfo::pretty_format (w.format ());
        string ds = glinfo::driver_info ();

        EXCEPTION_ASSERT(ws.find ("doubleBuffer") != std::string::npos);
        EXCEPTION_ASSERT(fs.find ("depthBufferSize") != std::string::npos);
        EXCEPTION_ASSERT(ws.find (fs) != std::string::npos);
        EXCEPTION_ASSERT(ds.find ("GL_ARB_depth_buffer_float") != std::string::npos);
    }
}
Esempio n. 8
0
GLView * GLView::create( NifSkope * window )
{
	QGLFormat fmt;
	static QList<QPointer<GLView> > views;

	QGLWidget * share = nullptr;
	for ( const QPointer<GLView>& v : views ) {
		if ( v )
			share = v;
	}

	// All new windows after the first window will share a format
	if ( share ) {
		fmt = share->format();
	} else {
		fmt.setSampleBuffers( Options::antialias() );
	}
	
	// OpenGL version
	fmt.setVersion( 2, 1 );
	// Ignored if version < 3.2
	//fmt.setProfile(QGLFormat::CoreProfile);

	// V-Sync
	fmt.setSwapInterval( 1 );
	fmt.setDoubleBuffer( true );

	fmt.setSamples( Options::antialias() ? 16 : 0 );

	fmt.setDirectRendering( true );
	fmt.setRgba( true );

	views.append( QPointer<GLView>( new GLView( fmt, window, share ) ) );

	return views.last();
}
Esempio n. 9
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
}