Exemple #1
0
int main(int argc, char *argv[])
{

    QApplication a(argc, argv);

    // Set OpenGL 3.2 and, optionally, 4-sample multisampling
    QSurfaceFormat format;
    format.setVersion(3, 2);
    format.setOption(QSurfaceFormat::DeprecatedFunctions, false);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setSamples(4);  // Uncomment for nice antialiasing. Not always supported.

    /*** AUTOMATIC TESTING: DO NOT MODIFY ***/
    /*** Check whether automatic testing is enabled */
    /***/if (qgetenv("CIS277_AUTOTESTING") != nullptr) {
        format.setSamples(0);
    }

    QSurfaceFormat::setDefaultFormat(format);
    debugFormatVersion();

    MainWindow w;
    w.show();

    return a.exec();
}
Exemple #2
0
int main(int argc, char **argv)
{
  QGuiApplication app(argc, argv);
  // create an OpenGL format specifier
  QSurfaceFormat format;
  // set the number of samples for multisampling
  // will need to enable glEnable(GL_MULTISAMPLE); once we have a context
  format.setSamples(4);
  format.setMajorVersion(3);
  format.setMinorVersion(2);
  // now we are going to set to Compat Profile OpenGL so we can use and old Immediate mode GL
  format.setProfile(QSurfaceFormat::CompatibilityProfile);
  // now set the depth buffer to 24 bits
  format.setDepthBufferSize(24);
  QSurfaceFormat::setDefaultFormat(format);
  // now we are going to create our scene window
  OpenGLWindow window;
  // we can now query the version to see if it worked
  std::cout<<"Profile is "<<format.majorVersion()<<" "<<format.minorVersion()<<"\n";
  // set the window size
  window.resize(1024, 720);
  // and finally show
  window.show();

  return app.exec();
}
GlWidget::GlWidget(QWidget *parent) : QOpenGLWidget(parent)
{
    QSurfaceFormat format;
    format.setDepthBufferSize(24);
    format.setSamples(24);
    setFormat(format);
    this->setMouseTracking(true);
    qApp->setOverrideCursor(Qt::BlankCursor);

    soundPlayer = new soundObject();
    soundPlayer->atAmbiend();

    connect(&timer, SIGNAL(timeout()), this, SLOT(eventLoop()));
    timer.setInterval(5);
    timer.start();

    currentTime.start();

    canonFire = false;
    horizontalAngle = 0.0f;
    verticalAngle = 0.0f;
    walkspeed = .05f;
    canonElevation= 0;
    canonTraverse = 180;

    camera[0].setX(0);
    camera[0].setY(0.75f);
    camera[0].setZ(0);

    camera[2].setX(0);
    camera[2].setY(1);
    camera[2].setZ(0);
}
OGLViewer::OGLViewer(QWidget *parent)
	: QOpenGLWidget(parent), mTimeCount(0), mFps(30)
	, mSelectMode(OBJECT_SELECT)
	, mViewCamera(new PerspectiveCamera(Point3f(10, 6, 11),
                                     Point3f(0, 0, 0),
                                     Vector3f(0, 1, 0),
                                     width() / float(height())))
	, box_mesh(new TriangleMesh("../../scene/obj/cube_large.obj"))
	, model_mesh(new TriangleMesh("../../scene/obj/monkey.obj"))
{
	// Set surface format for current widget
	QSurfaceFormat format;
	format.setDepthBufferSize(32);
	format.setStencilBufferSize(8);
	format.setSamples(4);
	format.setVersion(4, 5);
	format.setProfile(QSurfaceFormat::CoreProfile);
	this->setFormat(format);

	// Link timer trigger
	/*process_time.start();
	QTimer *timer = new QTimer(this);
	//timer->setSingleShot(false);
	connect(timer, SIGNAL(timeout()), this, SLOT(update()));
	timer->start(0);*/
}
Exemple #5
0
Window::Window(QScreen *screen) :
    QWindow (screen),
    scene_  (new BasicUsageScene)
{
    setSurfaceType(OpenGLSurface);

    QSurfaceFormat format;
    format.setDepthBufferSize(24);
    format.setMajorVersion(3);
    format.setMinorVersion(3);
    format.setSamples(4);
    format.setProfile(QSurfaceFormat::CoreProfile);

    resize(800, 600);
    setFormat(format);
    create();

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

    scene_->setContext(context_);
    initializeGl();

    connect(this, SIGNAL(widthChanged(int)), this, SLOT(resizeGl()));
    connect(this, SIGNAL(heightChanged(int)), this, SLOT(resizeGl()));
    resizeGl();

    QTimer* timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateScene()));
    timer->start(16);
}
Exemple #6
0
int main(int argc, char** argv) try {
    QApplication app(argc, argv);
    app.setApplicationDisplayName("Interactive OpenBC sim. interface");
    QSurfaceFormat fmt;
    fmt.setDepthBufferSize(24);
    //if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) {
        std::cout << "Using multisample" << std::endl;;
        fmt.setSamples(4);
    //}
    // Hard-coded to use the core profile.
    fmt.setVersion(3, 2);
    fmt.setProfile(QSurfaceFormat::CoreProfile);
    QSurfaceFormat::setDefaultFormat(fmt);
    
    MainWindow mainWindow;
    mainWindow.resize(mainWindow.sizeHint());
    int desktopArea = QApplication::desktop()->width()*QApplication::desktop()->height();
    int widgetArea = mainWindow.width()*mainWindow.height();
    if (((float)widgetArea / (float)desktopArea) < 0.75f) {
        mainWindow.show();
    } else {
        mainWindow.showMaximized();
    }
    return app.exec();
    
} catch (std::exception& e) {
    std::cout << "Caught exception: " << e.what() << std::endl;
} catch (...) {
    std::cout << "Caught unknown exception.\n";
}
Exemple #7
0
bool VideoWindow::initialize(Settings* settings)
{
	qDebug("Initializing video window");

	setSurfaceType(QWindow::OpenGLSurface);
	setIcon(QIcon(":/icons/misc/icons/orientview.ico"));
	setTitle("OrientView - Video");
	resize(settings->window.width, settings->window.height);
	setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), QApplication::desktop()->availableGeometry()));
	setWindowState(settings->window.fullscreen ? Qt::WindowFullScreen : Qt::WindowNoState);
	setCursor(settings->window.hideCursor ? Qt::BlankCursor : Qt::ArrowCursor);

	QSurfaceFormat surfaceFormat;
	surfaceFormat.setSamples(settings->window.multisamples);
	this->setFormat(surfaceFormat);

	context = new QOpenGLContext();
	context->setFormat(surfaceFormat);

	if (!context->create())
	{
		qWarning("Could not create OpenGL context");
		return false;
	}

	if (!context->makeCurrent(this))
	{
		qWarning("Could not make context current");
		return false;
	}

	isInitialized = true;

	return true;
}
Exemple #8
0
int main(int argc, char **argv)
{
    srand(time(NULL));
    QGuiApplication app(argc, argv);

    QSurfaceFormat format;
    format.setSamples(16);



    //1FPS
    /*GameWindow window1(60);
    window1.setFormat(format);
    window1.resize(960, 720);
    window1.setPosition(0,0);
    window1.show();


    window1.setAnimating(true);*/

    //30FPS
    GameWindow window30(60);
    window30.setFormat(format);
    window30.resize(960, 720);
    window30.setPosition(380,0);
    window30.show();

    window30.setAnimating(true);
    /*
        //60FPS
        GameWindow window60(60);
        window60.setFormat(format);
        window60.resize(320, 240);
        window60.setPosition(0,290);
        window60.show();

        window60.setAnimating(true);

        //120FPS
        GameWindow window120(120);
        window120.setFormat(format);
        window120.resize(340, 240);
        window120.setPosition(380,290);
        window120.show();

        window120.setAnimating(true);
    */
    Camera *c = new Camera();
    Camera *c1 = new Camera();
    c->setEtat(6);

    //window1.setCam(c1);
    window30.setCam(c);
    //window60.setCam(c);
    // window120.setCam(c);



    return app.exec();
}
Exemple #9
0
void MapView::setUseOpenGL(bool useOpenGL)
{
#ifndef QT_NO_OPENGL
    if (useOpenGL) {
        if (!qobject_cast<QOpenGLWidget*>(viewport())) {
            QSurfaceFormat format = QSurfaceFormat::defaultFormat();
            format.setDepthBufferSize(0);   // No need for a depth buffer
            format.setSamples(4);           // Enable anti-aliasing

            QOpenGLWidget *openGLWidget = new QOpenGLWidget(this);
            openGLWidget->setFormat(format);
            setViewport(openGLWidget);
        }
    } else {
        if (qobject_cast<QOpenGLWidget*>(viewport()))
            setViewport(nullptr);
    }

    QWidget *v = viewport();
    if (mMode == StaticContents)
        v->setAttribute(Qt::WA_StaticContents);
    v->setMouseTracking(true);
#else
    Q_UNUSED(useOpenGL)
#endif
}
Exemple #10
0
QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced)
{
    QSurfaceFormat retFormat = format;
    *reduced = true;

    if (retFormat.redBufferSize() > 1) {
        retFormat.setRedBufferSize(1);
    } else if (retFormat.greenBufferSize() > 1) {
        retFormat.setGreenBufferSize(1);
    } else if (retFormat.blueBufferSize() > 1) {
        retFormat.setBlueBufferSize(1);
    } else if (retFormat.samples() > 1) {
        retFormat.setSamples(qMin(retFormat.samples() / 2, 16));
    } else if (retFormat.stereo()) {
        retFormat.setStereo(false);
    }else if (retFormat.stencilBufferSize() > 0) {
        retFormat.setStencilBufferSize(0);
    }else if (retFormat.hasAlpha()) {
        retFormat.setAlphaBufferSize(0);
    }else if (retFormat.depthBufferSize() > 0) {
        retFormat.setDepthBufferSize(0);
    }else if (retFormat.swapBehavior() != QSurfaceFormat::SingleBuffer) {
        retFormat.setSwapBehavior(QSurfaceFormat::SingleBuffer);
    }else{
        *reduced = false;
    }
    return retFormat;
}
PrimaryFlightDisplayQML::PrimaryFlightDisplayQML(QWidget *parent) :
    QWidget(parent),
    m_declarativeView(NULL),
    m_uasInterface(NULL)
{
    QUrl url = QUrl::fromLocalFile(QGC::shareDirectory() + "/qml/PrimaryFlightDisplayQML.qml");
    QLOG_DEBUG() << url;
    if (!QFile::exists(QGC::shareDirectory() + "/qml/PrimaryFlightDisplayQML.qml"))
    {
        QMessageBox::information(0,"Error", "" + QGC::shareDirectory() + "/qml/PrimaryFlightDisplayQML.qml" + " not found. Please reinstall the application and try again");
        exit(-1);
    }
    m_declarativeView = new QQuickView();
    m_declarativeView->engine()->addImportPath("qml/"); //For local or win32 builds
    m_declarativeView->engine()->addImportPath(QGC::shareDirectory() +"/qml"); //For installed linux builds
    m_declarativeView->setSource(url);
    QSurfaceFormat format = m_declarativeView->format();
    format.setSamples(16);
    m_declarativeView->setFormat(format);

    QLOG_DEBUG() << "QML Status:" << m_declarativeView->status();
    m_declarativeView->setResizeMode(QQuickView::SizeRootObjectToView);
    QVBoxLayout* layout = new QVBoxLayout();
    QWidget *viewcontainer = QWidget::createWindowContainer(m_declarativeView);
    layout->addWidget(viewcontainer);
    setLayout(layout);
    setContentsMargins(0,0,0,0);
    show();

    // Connect with UAS
    connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this,
            SLOT(setActiveUAS(UASInterface*)), Qt::UniqueConnection);
    setActiveUAS(UASManager::instance()->getActiveUAS());

}
Exemple #12
0
int main(int argc, char *argv[])
{
    QApplication application(argc, argv);
    application.setApplicationName("repliqode");
    application.setOrganizationDomain("nous.ai");

    // Invert the palette, for reasons
    QPalette palette = QApplication::palette();

    for (int group = 0; group < QPalette::NColorGroups; group++) {
        QPalette::ColorGroup colorGroup = QPalette::ColorGroup(group);
        for (int role = 0; role < QPalette::NColorRoles; role++) {
            QPalette::ColorRole colorRole = QPalette::ColorRole(role);
            QColor color = palette.color(colorGroup, colorRole);
            QColor inverted(255 - color.red(), 255 - color.green(), 255 - color.blue(), color.alpha());
            palette.setColor(colorGroup, colorRole, inverted);
        }
    }
    QApplication::setPalette(palette);

    // Fix antialiasing quality of hive plot
    QSurfaceFormat fmt;
    fmt.setSamples(32);
    QSurfaceFormat::setDefaultFormat(fmt);

    Window window;
    window.showFullScreen();

    return application.exec();
}
int main(int argc, char **argv)
{
  // create an OpenGL format specifier
  QSurfaceFormat format;
  // set the number of samples for multisampling
  // will need to enable glEnable(GL_MULTISAMPLE); once we have a context
  format.setSamples(4);
  #if defined( DARWIN)
    // at present mac osx Mountain Lion only supports GL3.2
    // the new mavericks will have GL 4.x so can change
    format.setMajorVersion(4);
    format.setMinorVersion(2);
  #else
    // with luck we have the latest GL version so set to this
    format.setMajorVersion(4);
    format.setMinorVersion(3);
  #endif
  // now we are going to set to CoreProfile OpenGL so we can't use and old Immediate mode GL
  format.setProfile(QSurfaceFormat::CoreProfile);
  // now set the depth buffer to 24 bits
  format.setDepthBufferSize(24);
  // this will set the format for all widgets
  QSurfaceFormat::setDefaultFormat(format);
  // make an instance of the QApplication
  CebApplication a(argc, argv);
  // Create a new MainWindow
  MainWindow w;
  // show main window
  w.show();
  // show start dialog
  w.showStartDialog();

  // hand control over to Qt framework
  return a.exec();
}
Exemple #14
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    Q_INIT_RESOURCE(ARehab_vTerapeuta);

    QSurfaceFormat format;
    format.setVersion(4, 3);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setOption(QSurfaceFormat::DebugContext);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setSamples(4);
    format.setSwapInterval(0); //Disable VSync
    QSurfaceFormat::setDefaultFormat(format);

    ARehabGUIDesigner::ARehabMainWindow w;

    QFile styleFile(":/styles/main.qss");
    styleFile.open(QFile::ReadOnly);
    app.setStyleSheet(QLatin1String(styleFile.readAll()));
    styleFile.close();

    w.show();
    return (app.exec());
}
Exemple #15
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QSurfaceFormat fmt;
    fmt.setDepthBufferSize(24);
    if (QCoreApplication::arguments().contains(QStringLiteral("--multisample")))
        fmt.setSamples(4);
    if (QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"))) {
        fmt.setVersion(3, 2);
        fmt.setProfile(QSurfaceFormat::CoreProfile);
    }
    QSurfaceFormat::setDefaultFormat(fmt);

    MainWindow mainWindow;
    mainWindow.resize(mainWindow.sizeHint());
    int desktopArea = QApplication::desktop()->width() *
                     QApplication::desktop()->height();
    int widgetArea = mainWindow.width() * mainWindow.height();
    if (((float)widgetArea / (float)desktopArea) < 0.75f)
        mainWindow.show();
    else
        mainWindow.showMaximized();
    return app.exec();
}
Exemple #16
0
int main(int argc, char **argv)
{
  QGuiApplication app(argc, argv);
  // create an OpenGL format specifier
  QSurfaceFormat format;
  // set the number of samples for multisampling
  // will need to enable glEnable(GL_MULTISAMPLE); once we have a context
  format.setSamples(4);
  #if defined( __APPLE__)
    // at present mac osx Mountain Lion only supports GL3.2
    // the new mavericks will have GL 4.x so can change
    format.setMajorVersion(4);
    format.setMinorVersion(1);
  #else
    // with luck we have the latest GL version so set to this
    format.setMajorVersion(4);
    format.setMinorVersion(3);
  #endif
  // now we are going to set to CoreProfile OpenGL so we can't use and old Immediate mode GL
  format.setProfile(QSurfaceFormat::CoreProfile);
  // now set the depth buffer to 24 bits
  format.setDepthBufferSize(24);
  // now we are going to create our scene window
  NGLScene window;
  // and set the OpenGL format
  window.setFormat(format);
  // we can now query the version to see if it worked
  std::cout<<"Profile is "<<format.majorVersion()<<" "<<format.minorVersion()<<"\n";
  // set the window size
  // and finally show
  window.show();
  window.resize(1024, 720);

  return app.exec();
}
Exemple #17
0
int main( int argc, char* argv[] )
{
    QGuiApplication a( argc, argv );

    QStringList args = a.arguments();
    if ( args.size() != 2 )
    {
        qDebug() << "Please specify an obj file to load";
        exit( 1 );
    }
    const QString fileName = args.last();

    // Specify the format we wish to use
    QSurfaceFormat format;
    format.setMajorVersion( 3 );
#if !defined(Q_OS_MAC)
    format.setMinorVersion( 3 );
#else
    format.setMinorVersion( 2 );
#endif
    format.setDepthBufferSize( 24 );
    format.setSamples( 4 );
    format.setProfile( QSurfaceFormat::CoreProfile );

    OpenGLWindow w( format );
    w.setScene( new MultipleLightsScene( fileName ) );

    w.show();
    return a.exec();
}
Exemple #18
0
int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);

//    qmlRegisterType<TraceView>("SysViz", 1, 0, "TraceView");
    qmlRegisterType<ThreadSliceView>("SysViz", 1, 0, "ThreadSliceView");
    qmlRegisterType<GraphItem>      ("SysViz", 1, 0, "GraphItem");
    qmlRegisterType<TraceModel>();
    qmlRegisterType<QAbstractListModel>();
    qmlRegisterType<CpuFrequencyModel>();
    qmlRegisterType<GpuFrequencyModel>();

    TraceModel model;

    QQuickView view;
    QSurfaceFormat format = view.requestedFormat();
    format.setSamples(16);
    view.setFormat(format);

    view.rootContext()->setContextProperty("traceModel", &model);
    view.rootContext()->setContextProperty("cm", view.screen()->physicalDotsPerInch() / 2.54);

    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl::fromLocalFile("qml/main.qml"));
    view.setTitle("sysviz");
    view.show();

#ifdef QT_DQML_LIB
    DQmlLocalServer server(view.engine(), &view, "qml/main.qml");
    server.fileTracker()->track("qml", "qml");
#endif

    app.exec();
}
Exemple #19
0
Window::Window()
{
  QVBoxLayout *mainLayout = new QVBoxLayout;

  view  = new QGraphicsView(this);
  scene = new QGraphicsScene(view);

  view->setRenderHints(QPainter::Antialiasing);
  scene->setBackgroundBrush(Qt::blue);

  myGLWidget = new GLWidget(this);
  QOpenGLWidget *oglw = qobject_cast<QOpenGLWidget *>(myGLWidget);

  QSurfaceFormat format;
  format.setSamples(4);
  format.setDepthBufferSize(24);
  //format.setMajorVersion(3);
  //format.setMinorVersion(0);
  //format.setVersion(3,1);
  format.setProfile(QSurfaceFormat::CompatibilityProfile);
  oglw->setFormat(format);

  view->setViewport(myGLWidget);
  view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

  view->setScene(scene);

  mainLayout->addWidget(view);
  setLayout(mainLayout);

  setWindowTitle(tr("GraphicsView + OpenGL Test Unit"));
}
Exemple #20
0
UiRenderPreview::UiRenderPreview(QWidget *parent, void *shared) :
    QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::DirectRendering), parent, (QGLWidget*)shared) {
#else
UiRenderPreview::UiRenderPreview(QWidget *parent, void *shared) :
    QOpenGLWidget(parent) {
    Q_UNUSED(shared);
    QSurfaceFormat sf;
    //sf.setProfile(QSurfaceFormat::CompatibilityProfile);
    //sf.setRenderableType(QSurfaceFormat::OpenGL);
    //sf.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    //sf.setOption(QSurfaceFormat::DeprecatedFunctions);
    sf.setSamples(4./devicePixelRatioFScale());
    setFormat(sf);
#endif
    setFocusPolicy(Qt::StrongFocus);
    render = 0;
}

void UiRenderPreview::initializeGL() {
    //OpenGL options
}

void UiRenderPreview::resizeGL(int width, int height) {
    glViewport(0, 0, (GLint)width, (GLint)height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 1, 0, 1, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
void QMinimalEglScreen::createAndSetPlatformContext()
{
    QSurfaceFormat platformFormat;

    QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH");
    if (depthString.toInt() == 16) {
        platformFormat.setDepthBufferSize(16);
        platformFormat.setRedBufferSize(5);
        platformFormat.setGreenBufferSize(6);
        platformFormat.setBlueBufferSize(5);
        m_depth = 16;
        m_format = QImage::Format_RGB16;
    } else {
        platformFormat.setDepthBufferSize(24);
        platformFormat.setStencilBufferSize(8);
        platformFormat.setRedBufferSize(8);
        platformFormat.setGreenBufferSize(8);
        platformFormat.setBlueBufferSize(8);
        m_depth = 32;
        m_format = QImage::Format_RGB32;
    }

    if (!qEnvironmentVariableIsEmpty("QT_QPA_EGLFS_MULTISAMPLE"))
        platformFormat.setSamples(4);

    EGLConfig config = q_configFromGLFormat(m_dpy, platformFormat);

    EGLNativeWindowType eglWindow = 0;
#ifdef Q_OPENKODE
    if (kdInitializeNV() == KD_ENOTINITIALIZED) {
        qFatal("Did not manage to initialize openkode");
    }
    KDWindow *window = kdCreateWindow(m_dpy,config,0);

    kdRealizeWindow(window,&eglWindow);
#endif

#ifdef QEGL_EXTRA_DEBUG
    q_printEglConfig(m_dpy, config);
#endif

    m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL);
    if (m_surface == EGL_NO_SURFACE) {
        qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError());
        eglTerminate(m_dpy);
        qFatal("EGL error");
    }
    //    qWarning("Created surface %dx%d\n", w, h);

    QEGLPlatformContext *platformContext = new QMinimalEglContext(platformFormat, 0, m_dpy);
    m_platformContext = platformContext;

    EGLint w,h;                    // screen size detection
    eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w);
    eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h);

    m_geometry = QRect(0,0,w,h);

}
Exemple #22
0
int main(int argc, char ** argv)
{
	ShowWindow(GetConsoleWindow(), SW_HIDE);

	QApplication app(argc, argv);

	QSurfaceFormat format;
	format.setDepthBufferSize(4);
	format.setSamples(24);
	format.setVersion(4, 4);
	format.setRenderableType(QSurfaceFormat::OpenGL);

	OpenGLWidget window;
	window.setFormat(format);
	window.resize(WINDOW_WIDTH, WINDOW_HEIGHT);

	selector = new ShaderFinder();

	pane = new CollapsiblePanelWidget(&window);
	pane->setStyleSheet("background-color:white");
	pane->setWidgetResizable(true);
	pane->setGeometry(0, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT);
	pane->duration = 500;
	pane->config(QRect(0, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT), QRect(-WINDOW_WIDTH / 5, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT));

	paneBox = new QGroupBox();
	pane->setWidget(paneBox);

	paneLayout = new QVBoxLayout();
	paneLayout->setSpacing(10);
	paneLayout->setAlignment(Qt::AlignTop);
	paneLayout->addWidget(selector);

	pane->widget()->setLayout(paneLayout);
	pane->show();

	anim = new CollapsiblePanelWidget(&window);
	anim->setStyleSheet("background-color:white");
	anim->setWidgetResizable(true);
	anim->setGeometry(WINDOW_WIDTH * 0.8, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT);
	anim->duration = 500;
	anim->config(QRect(WINDOW_WIDTH * 0.8, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT), QRect(WINDOW_WIDTH, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT));

	animBox = new QGroupBox();
	anim->setWidget(animBox);

	animLayout = new QVBoxLayout();
	animLayout->setSpacing(10);
	animLayout->setAlignment(Qt::AlignTop);

	anim->widget()->setLayout(animLayout);
	anim->show();

	window.show();

	return app.exec();
}
Exemple #23
0
void MainWindow::updateView()
{
    QSurfaceFormat format;
    format.setDepthBufferSize(16);
    format.setStencilBufferSize(8);
    if (m_transparent)
        format.setAlphaBufferSize(8);
    if (m_checkboxMultiSample->isChecked())
        format.setSamples(4);

    State state = m_radioView->isChecked() ? UseWindow : UseWidget;

    if (m_format == format && m_state == state)
        return;

    m_format = format;
    m_state = state;

    QString text = m_currentRootObject
            ? m_currentRootObject->property("currentText").toString()
            : QStringLiteral("Hello Qt");

    QUrl source("qrc:qquickviewcomparison/test.qml");

    if (m_state == UseWindow) {
        QQuickView *quickView = new QQuickView;
        // m_transparent is not supported here since many systems have problems with semi-transparent child windows
        quickView->setFormat(m_format);
        quickView->setResizeMode(QQuickView::SizeRootObjectToView);
        connect(quickView, &QQuickView::statusChanged, this, &MainWindow::onStatusChangedView);
        connect(quickView, &QQuickView::sceneGraphError, this, &MainWindow::onSceneGraphError);
        quickView->setSource(source);
        m_currentRootObject = quickView->rootObject();
        switchTo(QWidget::createWindowContainer(quickView));
    } else if (m_state == UseWidget) {
        QQuickWidget *quickWidget = new QQuickWidget;
        if (m_transparent) {
            quickWidget->setClearColor(Qt::transparent);
            quickWidget->setAttribute(Qt::WA_TranslucentBackground);
        }
        quickWidget->setFormat(m_format);
        quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
        connect(quickWidget, &QQuickWidget::statusChanged, this, &MainWindow::onStatusChangedWidget);
        connect(quickWidget, &QQuickWidget::sceneGraphError, this, &MainWindow::onSceneGraphError);
        quickWidget->setSource(source);
        m_currentRootObject = quickWidget->rootObject();
        switchTo(quickWidget);
    }

    if (m_currentRootObject) {
        m_currentRootObject->setProperty("currentText", text);
        m_currentRootObject->setProperty("multisample", m_checkboxMultiSample->isChecked());
        m_currentRootObject->setProperty("translucency", m_transparent);
    }

    m_overlayLabel->raise();
}
Exemple #24
0
Window::Window()
  : QOpenGLWidget()
{
  QSurfaceFormat format;
  format.setSamples(8);
  format.setStencilBufferSize(8);
  setFormat(format);
  printf("Version Major:%d minor:%d \n",format.version().first, format.version().second);
  datachanged = colorchanged = true;
}
Exemple #25
0
void QGLView::setupWindow()
{
    connect(window()->openglContext(), SIGNAL(aboutToBeDestroyed()),
            this, SLOT(cleanup()), Qt::DirectConnection);

    QSurfaceFormat format = window()->format();
    format.setDepthBufferSize(24);
    format.setSamples(4);
    window()->setFormat(format);
}
Exemple #26
0
QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat)
{
    QSurfaceFormat format;
    EGLint redSize     = 0;
    EGLint greenSize   = 0;
    EGLint blueSize    = 0;
    EGLint alphaSize   = 0;
    EGLint depthSize   = 0;
    EGLint stencilSize = 0;
    EGLint sampleCount = 0;
    EGLint renderableType = 0;

    eglGetConfigAttrib(display, config, EGL_RED_SIZE,     &redSize);
    eglGetConfigAttrib(display, config, EGL_GREEN_SIZE,   &greenSize);
    eglGetConfigAttrib(display, config, EGL_BLUE_SIZE,    &blueSize);
    eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE,   &alphaSize);
    eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE,   &depthSize);
    eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
    eglGetConfigAttrib(display, config, EGL_SAMPLES,      &sampleCount);
    eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &renderableType);

    if (referenceFormat.renderableType() == QSurfaceFormat::OpenVG && (renderableType & EGL_OPENVG_BIT))
        format.setRenderableType(QSurfaceFormat::OpenVG);
#ifdef EGL_VERSION_1_4
    else if (referenceFormat.renderableType() == QSurfaceFormat::OpenGL
             && (renderableType & EGL_OPENGL_BIT))
        format.setRenderableType(QSurfaceFormat::OpenGL);
    else if (referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType
#ifndef QT_NO_OPENGL
             && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
#endif
             && (renderableType & EGL_OPENGL_BIT))
        format.setRenderableType(QSurfaceFormat::OpenGL);
#endif
    else
        format.setRenderableType(QSurfaceFormat::OpenGLES);

    format.setRedBufferSize(redSize);
    format.setGreenBufferSize(greenSize);
    format.setBlueBufferSize(blueSize);
    format.setAlphaBufferSize(alphaSize);
    format.setDepthBufferSize(depthSize);
    format.setStencilBufferSize(stencilSize);
    format.setSamples(sampleCount);
    format.setStereo(false);         // EGL doesn't support stereo buffers
    format.setSwapInterval(referenceFormat.swapInterval());

    // Clear the EGL error state because some of the above may
    // have errored out because the attribute is not applicable
    // to the surface type.  Such errors don't matter.
    eglGetError();

    return format;
}
    GLWindow(Qt::WindowFlags flags)
        : gl(0)
    {
        setFlags(flags);
        setSurfaceType(OpenGLSurface);

        QSurfaceFormat format;
        format.setAlphaBufferSize(8);
        format.setSamples(16);
        setFormat(format);
    }
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QSurfaceFormat fmt;
    fmt.setSamples(4);
    QSurfaceFormat::setDefaultFormat(fmt);

    Window window;
    window.show();
    return app.exec();
}
Exemple #29
0
void MyThread::run()
{
    QSurfaceFormat format;
    format.setSamples(16);

    GameWindowClient clientWindow (50,&m_camera,m_name);
    clientWindow.setFormat(format);
    clientWindow.resize(640, 480);
    clientWindow.show();


}
Exemple #30
0
bool EncodeWindow::initialize(VideoDecoder* videoDecoder, VideoEncoderThread* videoEncoderThread, Settings* settings)
{
	qDebug("Initializing encode window");

	this->videoEncoderThread = videoEncoderThread;

	setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
	resize(10, 10);

	QSurfaceFormat surfaceFormat;
	surfaceFormat.setSamples(settings->window.multisamples);

	surface = new QOffscreenSurface();
	surface->setFormat(surfaceFormat);
	surface->create();

	if (!surface->isValid())
	{
		qWarning("Could not create offscreen surface");
		return false;
	}

	context = new QOpenGLContext();
	context->setFormat(surfaceFormat);

	if (!context->create())
	{
		qWarning("Could not create OpenGL context");
		return false;
	}

	if (!context->makeCurrent(surface))
	{
		qWarning("Could not make context current");
		return false;
	}

	totalFrameCount = videoDecoder->getTotalFrameCount();
	videoFilePath = settings->encoder.outputVideoFilePath;

	QTime totalVideoDuration = QTime(0, 0, 0, 0).addMSecs(videoDecoder->getTotalDuration() * 1000.0);

	ui->progressBarMain->setValue(0);
	ui->labelTotalVideoDuration->setText(totalVideoDuration.toString());
	ui->labelTotalFrames->setText(QString::number(totalFrameCount));
	ui->pushButtonOpen->setEnabled(false);

	startTime.start();

	isInitialized = true;

	return true;
}