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


C++ QOpenGLContext::swapBuffers方法代码示例

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


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

示例1:

void
WebView::CreateGLContext() {
  QOpenGLContext* context = window_->GLContext();
  context->makeCurrent(window_);

  static bool firstClearDone = false;
  if (!firstClearDone) {
    QOpenGLFunctions* functions = context->functions();
    Q_ASSERT(functions);
    functions->glClearColor(1.0, 1.0, 1.0, 0.0);
    functions->glClear(GL_COLOR_BUFFER_BIT);
    context->swapBuffers(window_);
    firstClearDone = true;
  }
}
开发者ID:tworaz,项目名称:qzilla,代码行数:15,代码来源:webview.cpp

示例2: draw

void TestWindow::draw() {
    if (_aboutToQuit) {
        return;
    }

    // Attempting to draw before we're visible and have a valid size will
    // produce GL errors.
    if (!isVisible() || _size.width() <= 0 || _size.height() <= 0) {
        return;
    }

    static std::once_flag once;
    std::call_once(once, [&] { initGl(); });

    if (!_glContext.makeCurrent(this)) {
        return;
    }

    updateSurfaces();

    auto size = this->geometry().size();
    auto incrementX = size.width() / DIVISIONS_X;
    auto incrementY = size.height() / DIVISIONS_Y;
    _glf.glViewport(0, 0, size.width(), size.height());
    _glf.glClearColor(1, 0, 0, 1);
    _glf.glClear(GL_COLOR_BUFFER_BIT);
    for (uint32_t x = 0; x < DIVISIONS_X; ++x) {
        for (uint32_t y = 0; y < DIVISIONS_Y; ++y) {
            auto& qmlInfo = _surfaces[x][y];
            if (!qmlInfo.surface || !qmlInfo.texture) {
                continue;
            }
            _glf.glBindFramebuffer(GL_READ_FRAMEBUFFER, _fbo);
            _glf.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, qmlInfo.texture, 0);
            _glf.glBlitFramebuffer(
                // src coordinates
                0, 0, _qmlSize.width() - 1, _qmlSize.height() - 1,
                // dst coordinates
                incrementX * x, incrementY * y, incrementX * (x + 1), incrementY * (y + 1),
                // blit mask and filter
                GL_COLOR_BUFFER_BIT, GL_NEAREST);
        }
    }
    _glf.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
    _glf.glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
    _glContext.swapBuffers(this);
}
开发者ID:SeijiEmery,项目名称:hifi,代码行数:47,代码来源:main.cpp

示例3:

void OculusWin32DisplayPlugin::postRender() {
    _context->swapBuffers(_window);
}
开发者ID:geekmaster,项目名称:ShadertoyVR-1,代码行数:3,代码来源:OculusWin32.cpp

示例4: focusObject

void tst_QGuiApplication::focusObject()
{
    int argc = 0;
    QGuiApplication app(argc, 0);

    if (qApp->platformName().toLower() == QLatin1String("wayland"))
        QSKIP("Wayland: This fails. Figure out why.");

    QObject obj1, obj2, obj3;
    const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();

    DummyWindow window1;
#if defined(Q_OS_QNX)
    window1.setSurfaceType(QSurface::OpenGLSurface);
#endif
    window1.resize(windowSize, windowSize);
    window1.setTitle(QStringLiteral("focusObject:window1"));
    window1.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing));
    DummyWindow window2;
    window2.resize(windowSize, windowSize);
    window2.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing));
    window2.setTitle(QStringLiteral("focusObject:window2"));

    window1.show();

#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store
                      // and then post the window in order for screen to show the window
    QOpenGLContext context;
    context.create();
    context.makeCurrent(&window1);
    QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window
    context.swapBuffers(&window1);
#endif

    QSignalSpy spy(&app, SIGNAL(focusObjectChanged(QObject*)));


    // verify active window focus propagates to qguiapplication
    window1.requestActivate();
    QVERIFY(QTest::qWaitForWindowActive(&window1));
    QCOMPARE(app.focusWindow(), &window1);

    window1.setFocusObject(&obj1);
    QCOMPARE(app.focusObject(), &obj1);
    QCOMPARE(spy.count(), 1);

    spy.clear();
    window1.setFocusObject(&obj2);
    QCOMPARE(app.focusObject(), &obj2);
    QCOMPARE(spy.count(), 1);

    spy.clear();
    window2.setFocusObject(&obj3);
    QCOMPARE(app.focusObject(), &obj2); // not yet changed
    window2.show();
    QVERIFY(QTest::qWaitForWindowExposed(&window2));
    QTRY_COMPARE(app.focusWindow(), &window2);
    QCOMPARE(app.focusObject(), &obj3);
    QCOMPARE(spy.count(), 1);

    // focus change on unfocused window does not show
    spy.clear();
    window1.setFocusObject(&obj1);
    QCOMPARE(spy.count(), 0);
    QCOMPARE(app.focusObject(), &obj3);
}
开发者ID:oneywang,项目名称:qtbase,代码行数:66,代码来源:tst_qguiapplication.cpp


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