本文整理汇总了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;
}
}
示例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);
}
示例3:
void OculusWin32DisplayPlugin::postRender() {
_context->swapBuffers(_window);
}
示例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);
}