本文整理汇总了C++中GLWidget::context方法的典型用法代码示例。如果您正苦于以下问题:C++ GLWidget::context方法的具体用法?C++ GLWidget::context怎么用?C++ GLWidget::context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLWidget
的用法示例。
在下文中一共展示了GLWidget::context方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
QSurfaceFormat format;
format.setDepthBufferSize(16);
QSurfaceFormat::setDefaultFormat(format);
// Two top-level windows with two QOpenGLWidget children in each.
// The rendering for the four QOpenGLWidgets happens on four separate threads.
GLWidget topLevelGlWidget;
QPoint pos = QApplication::desktop()->availableGeometry(&topLevelGlWidget).topLeft() + QPoint(200, 200);
topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level"));
topLevelGlWidget.resize(200, 200);
topLevelGlWidget.move(pos);
topLevelGlWidget.show();
const QString glInfo = getGlString(topLevelGlWidget.context()->functions(), GL_VENDOR)
+ QLatin1Char('/') + getGlString(topLevelGlWidget.context()->functions(), GL_RENDERER);
const bool supportsThreading = !glInfo.contains(QLatin1String("nouveau"), Qt::CaseInsensitive)
&& !glInfo.contains(QLatin1String("ANGLE"), Qt::CaseInsensitive)
&& !glInfo.contains(QLatin1String("llvmpipe"), Qt::CaseInsensitive);
const QString toolTip = supportsThreading ? glInfo : glInfo + QStringLiteral("\ndoes not support threaded OpenGL.");
topLevelGlWidget.setToolTip(toolTip);
QScopedPointer<MainWindow> mw1;
QScopedPointer<MainWindow> mw2;
if (!QApplication::arguments().contains(QStringLiteral("--single"))) {
if (supportsThreading) {
pos += QPoint(100, 100);
mw1.reset(new MainWindow);
mw1->setToolTip(toolTip);
mw1->move(pos);
mw1->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #1"));
mw1->show();
pos += QPoint(100, 100);
mw2.reset(new MainWindow);
mw2->setToolTip(toolTip);
mw2->move(pos);
mw2->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #2"));
mw2->show();
} else {
qWarning() << toolTip;
}
}
return a.exec();
}