当前位置: 首页>>代码示例>>C++>>正文


C++ QSurfaceFormat::setMinorVersion方法代码示例

本文整理汇总了C++中QSurfaceFormat::setMinorVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat::setMinorVersion方法的具体用法?C++ QSurfaceFormat::setMinorVersion怎么用?C++ QSurfaceFormat::setMinorVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSurfaceFormat的用法示例。


在下文中一共展示了QSurfaceFormat::setMinorVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv) {
    ::testing::InitGoogleTest(&argc, argv);

    QGuiApplication app(argc, argv);
    Q_UNUSED(app);

    QSurfaceFormat format;
    format.setMajorVersion(3);
    format.setMinorVersion(0);

    QOpenGLContext context;
    context.setFormat(format);
    context.create();
    if (!context.isValid()) return 1;
    qDebug() << QString::fromLatin1("Context created.");

    QOffscreenSurface surface;
    surface.setFormat(format);
    surface.create();
    if(!surface.isValid()) return 2;
    qDebug() << QString::fromLatin1("Surface created.");

    context.makeCurrent(&surface);

    return RUN_ALL_TESTS();
}
开发者ID:d-meiser,项目名称:mosaic,代码行数:26,代码来源:mosaicviewrenderer_test.cpp

示例2: main

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();
}
开发者ID:QtOpenGL,项目名称:opengl-demos,代码行数:30,代码来源:main.cpp

示例3: d

QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
    : d(new QGLTemporaryContextPrivate)
{
    d->oldContext = const_cast<QGLContext *>(QGLContext::currentContext());

    d->window = new QWindow;
    d->window->setSurfaceType(QWindow::OpenGLSurface);
    d->window->setGeometry(QRect(0, 0, 3, 3));
    d->window->create();

    d->context = new QOpenGLContext;
#if !defined(QT_OPENGL_ES)
    // On desktop, request latest released version
    QSurfaceFormat format;
#if defined(Q_OS_MAC)
    // OS X is limited to OpenGL 3.2 Core Profile at present
    // so set that here. If we use compatibility profile it
    // only reports 2.x contexts.
    format.setMajorVersion(3);
    format.setMinorVersion(2);
    format.setProfile(QSurfaceFormat::CoreProfile);
#else
    format.setMajorVersion(4);
    format.setMinorVersion(3);
#endif
    d->context->setFormat(format);
#endif
    d->context->create();
    d->context->makeCurrent(d->window);
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:30,代码来源:qgl_qpa.cpp

示例4: main

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();
}
开发者ID:JFDesigner,项目名称:Camera,代码行数:35,代码来源:main.cpp

示例5: main

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();
}
开发者ID:JFDesigner,项目名称:ShaderEnvironmentBuilder,代码行数:35,代码来源:main.cpp

示例6: QWindow

GLWindow::GLWindow(QScreen *screen) : QWindow(screen) {

    QSurfaceFormat cformat;
    cformat.setDepthBufferSize(24);
    cformat.setMajorVersion(4);
    cformat.setMinorVersion(2);
    cformat.setProfile(QSurfaceFormat::CoreProfile);
    
    resize(800,600);
    setSurfaceType(OpenGLSurface);
    create();

    _context = new QOpenGLContext;
    _context->setFormat(cformat);
    _context->create();

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

    initializeGL();
    resizeGL();

    /*QTimer* timer = new QTimer(this);
    connect( timer, SIGNAL(timeout()), this, SLOT(update()));
    timer->start();*/
}
开发者ID:duglah,项目名称:KoRE,代码行数:26,代码来源:GLWindow.cpp

示例7: getDefaultOpenGLSurfaceFormat

const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
    static QSurfaceFormat format;
    static std::once_flag once;
    std::call_once(once, [] {
#if defined(USE_GLES)
        format.setRenderableType(QSurfaceFormat::OpenGLES);
        format.setRedBufferSize(8);
        format.setGreenBufferSize(8);
        format.setBlueBufferSize(8);
        format.setAlphaBufferSize(8);
#else
        format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
#endif
        if (gl::Context::enableDebugLogger()) {
            format.setOption(QSurfaceFormat::DebugContext);
        }
        // Qt Quick may need a depth and stencil buffer. Always make sure these are available.
        format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS);
        format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS);
        int major, minor;
        ::gl::getTargetVersion(major, minor);
        format.setMajorVersion(major);
        format.setMinorVersion(minor);
    });
    return format;
}
开发者ID:Menithal,项目名称:hifi,代码行数:26,代码来源:GLHelpers.cpp

示例8: QWindow

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);
}
开发者ID:jholownia,项目名称:qtgl,代码行数:32,代码来源:window.cpp

示例9: main

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();
}
开发者ID:NCCA,项目名称:OpenGLCode,代码行数:26,代码来源:main.cpp

示例10: QOpenGLWidget

RenderWidget::RenderWidget(QWidget *parent) :
  QOpenGLWidget(parent),
  renderFunctions(nullptr),
  render(nullptr),
  quad(nullptr),
  quadShader(nullptr),
  openglDebugLogger(nullptr),
  captureMouse(false),
  onlyShowTexture(false),
  textureDisplayed(color)
{
  // Widget config
  setUpdateBehavior(QOpenGLWidget::NoPartialUpdate);
  setFocusPolicy(Qt::ClickFocus);

  // Update Timer config
  connect(&updateTimer, SIGNAL(timeout()), this, SLOT(update()));
  startUpdateLoop();

  // Open GL Context config
  QSurfaceFormat f;
  f.setRenderableType(QSurfaceFormat::OpenGL);
  f.setMajorVersion(4);
  f.setMinorVersion(5);
  f.setProfile(QSurfaceFormat::CoreProfile);
  f.setOptions(QSurfaceFormat::DebugContext | f.options());
  setFormat(f);
}
开发者ID:lamogui,项目名称:rmeditor,代码行数:28,代码来源:renderwidget.cpp

示例11: reserved

ContextPoolContext::ContextPoolContext(QOpenGLContext* share_context, bool reserved)
    : reserved(reserved), count(0), surface(NULL), context(NULL)
{
    QSurfaceFormat format;
    format.setMajorVersion(3);
    format.setMinorVersion(2);
    format.setSwapInterval(0);
    format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setOption(QSurfaceFormat::DebugContext);
    surface = new QOffscreenSurface();
    surface->setFormat(format);
    surface->create();
    if (!surface->isValid()) {
        throw;
    }

    context = new QOpenGLContext();
    context->setShareContext(share_context);
    context->setFormat(surface->requestedFormat());

    if (!context->create()) {
        throw;
    }

    context->makeCurrent(surface);
    gl = context->versionFunctions<QOpenGLFunctions_3_2_Core>();
    if (gl == nullptr || !gl->initializeOpenGLFunctions()) {
        throw;
    }
    indirect = new QOpenGLExtension_ARB_multi_draw_indirect();
    if (!indirect->initializeOpenGLFunctions()) {
        throw;
    }
    vab = new QOpenGLExtension_ARB_vertex_attrib_binding();
    if (!vab->initializeOpenGLFunctions()) {
        throw;
    }
    sso = new QOpenGLExtension_ARB_separate_shader_objects();
    if (!sso->initializeOpenGLFunctions()) {
        throw;
    }
    tex = new QOpenGLExtension_ARB_texture_buffer_object();
    if (!tex->initializeOpenGLFunctions()) {
        throw;
    }
    buffer = (QOpenGLExtension_ARB_buffer_storage)context->getProcAddress("glBufferStorage");
    debug = new QOpenGLExtension_ARB_debug_output();
    if (!debug->initializeOpenGLFunctions()) {
        throw;
    }
    debug->glDebugMessageCallbackARB(debug_callback, nullptr);
    debug->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_FALSE);
    debug->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, 0, GL_TRUE);
    context->doneCurrent();
    context->moveToThread(nullptr);
}
开发者ID:x414e54,项目名称:x3d-compositor,代码行数:58,代码来源:openglhelper.cpp

示例12: controlContext

void HsQMLContextControl::controlContext()
{
    // Do nothing if no window
    if (!mWindow) {
        return;
    }

    // Do nothing if changes are being deferred
    if (mDefer || !mWhen) {
        mPending = true;
        return;
    }
    mPending = false;

    QSurfaceFormat fmt = mOriginal;
    if (mMajorVersion >= 0) {
        fmt.setMajorVersion(mMajorVersion);
    }
    if (mMinorVersion >= 0) {
        fmt.setMinorVersion(mMinorVersion);
    }
    if (mContextType >= 0) {
        fmt.setRenderableType(static_cast<QSurfaceFormat::RenderableType>(
            mContextType));
    }
    if (mContextProfile >= 0) {
        fmt.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>(
            mContextProfile));
    }
    if (mDeprecatedFunctionsSet) {
#if QT_VERSION >= 0x050300
        fmt.setOption(QSurfaceFormat::DeprecatedFunctions,
            mDeprecatedFunctions);
#else
        if (mDeprecatedFunctions) {
            fmt.setOption(QSurfaceFormat::DeprecatedFunctions);
        }
#endif
    }
    fmt.setDepthBufferSize(qMax(fmt.depthBufferSize(), mDepthBufferSize));
    fmt.setStencilBufferSize(qMax(fmt.stencilBufferSize(), mStencilBufferSize));
    if (fmt == mWindow->requestedFormat()) {
        return;
    }
    mWindow->setFormat(fmt);

    // Recreate OpenGL context
    mWindow->setPersistentOpenGLContext(false);
    mWindow->setPersistentSceneGraph(false);
    bool visible = mWindow->isVisible();
    mWindow->destroy();
    mWindow->releaseResources();
    mWindow->setVisible(visible);
    mWindow->setPersistentOpenGLContext(true);
    mWindow->setPersistentSceneGraph(true);
}
开发者ID:johntyree,项目名称:HsQML,代码行数:56,代码来源:Canvas.cpp

示例13: Init

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool COpenVROverlayController::Init()
{
	bool bSuccess = true;

    m_strName = "Alerts";

	QSurfaceFormat format;
	format.setMajorVersion( 4 );
	format.setMinorVersion( 1 );
	format.setProfile( QSurfaceFormat::CompatibilityProfile );

	m_pOpenGLContext = new QOpenGLContext();
	m_pOpenGLContext->setFormat( format );
	bSuccess = m_pOpenGLContext->create();
	if( !bSuccess )
		return false;

	// create an offscreen surface to attach the context and FBO to
	m_pOffscreenSurface = new QOffscreenSurface();
	m_pOffscreenSurface->create();
	m_pOpenGLContext->makeCurrent( m_pOffscreenSurface );

	m_pScene = new QGraphicsScene();
	connect( m_pScene, SIGNAL(changed(const QList<QRectF>&)), this, SLOT( OnSceneChanged(const QList<QRectF>&)) );

	// Loading the OpenVR Runtime
	bSuccess = ConnectToVRRuntime();

    bSuccess = bSuccess && vr::VRCompositor() != NULL;

    if( vr::VROverlay() )
	{
        std::string sKey = "texasgamer.openvr-notifications.overlay.Alerts";
        vr::VROverlayError overlayError = vr::VROverlay()->CreateDashboardOverlay(sKey.c_str(), "Alerts", &m_ulOverlayHandle, &m_ulOverlayThumbnailHandle);
        QString name = qApp->applicationDirPath() + "/resources/overlay-icon.png";
        vr::VROverlay()->SetOverlayFromFile(m_ulOverlayThumbnailHandle, name.toUtf8().constData());
		bSuccess = bSuccess && overlayError == vr::VROverlayError_None;
	}

	if( bSuccess )
	{
        vr::VROverlay()->SetOverlayWidthInMeters( m_ulOverlayHandle, 1.5f );
        vr::VROverlay()->SetOverlayInputMethod( m_ulOverlayHandle, vr::VROverlayInputMethod_Mouse );
	
		m_pPumpEventsTimer = new QTimer( this );
		connect(m_pPumpEventsTimer, SIGNAL( timeout() ), this, SLOT( OnTimeoutPumpEvents() ) );
		m_pPumpEventsTimer->setInterval( 20 );
        m_pPumpEventsTimer->start();
        qInfo() << "Connected with OpenVR.";
    } else {
        qInfo() << "Unable to start openvr-notifications. Unable to connect with OpenVR.";
    }

	return true;
}
开发者ID:GrindheadJim,项目名称:zephyr,代码行数:58,代码来源:openvroverlaycontroller.cpp

示例14: main

int main(int argc, char *argv[])
{
    QGuiApplication a(argc,argv);
    Window w;
    QSurfaceFormat f = w.requestedFormat();
    f.setMajorVersion(3);
    f.setMinorVersion(3);
    w.setFormat(f);
    w.setWidth(640);
    w.setHeight(480);
    w.show();
    return a.exec();
}
开发者ID:NelsonBilber,项目名称:computer-graphics,代码行数:13,代码来源:main.cpp

示例15: main

int main( int argc, char* argv[] )
{
    QGuiApplication a( argc, argv );

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

    Window w( format );
    w.setScene( new TerrainTessellationScene );

    w.show();
    return a.exec();
}
开发者ID:QtOpenGL,项目名称:opengl-demos,代码行数:22,代码来源:main.cpp


注:本文中的QSurfaceFormat::setMinorVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。