本文整理汇总了C++中QSurfaceFormat::setVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat::setVersion方法的具体用法?C++ QSurfaceFormat::setVersion怎么用?C++ QSurfaceFormat::setVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSurfaceFormat
的用法示例。
在下文中一共展示了QSurfaceFormat::setVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
qInstallMessageHandler(&handleMessageOutput);
QApplication app(argc, argv);
std::vector<QSurfaceFormat> formats;
#if !defined(QT_OPENGL_ES)
{
QSurfaceFormat glFormat;
glFormat.setRenderableType(QSurfaceFormat::OpenGL);
glFormat.setProfile(QSurfaceFormat::CoreProfile);
glFormat.setVersion(4,3);
formats.push_back(glFormat);
}
#endif
#if defined(QT_OPENGL_ES)
{
QSurfaceFormat glesFormat;
glesFormat.setRenderableType(QSurfaceFormat::OpenGLES);
glesFormat.setProfile(QSurfaceFormat::CoreProfile);
glesFormat.setVersion(3,0);
formats.push_back(glesFormat);
}
#endif
// Find out which version we support
QSurfaceFormat *format = getFirstSupported(formats);
if (format == NULL)
{
QMessageBox::critical(0, "Critical Error", "No valid supported version of OpenGL found on device!");
exit(-1);
}
#ifdef GL_DEBUG
format->setOption(QSurfaceFormat::DebugContext);
#endif // GL_DEBUG
format->setDepthBufferSize(0);
// Set the widget up
MainWidget *widget = new MainWidget;
widget->setFormat(*format);
// Set the window up
MainWindow *window = new MainWindow;
window->show();
return app.exec();
}
示例2: RunTestInOpenGLOffscreenEnvironment
void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES3,
TestFunction const & fn)
{
std::vector<char> buf(strlen(testName) + 1);
strcpy(buf.data(), testName);
char * raw = buf.data();
int argc = 1;
QApplication app(argc, &raw);
QSurfaceFormat fmt;
fmt.setAlphaBufferSize(8);
fmt.setBlueBufferSize(8);
fmt.setGreenBufferSize(8);
fmt.setRedBufferSize(8);
fmt.setStencilBufferSize(0);
fmt.setSamples(0);
fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
fmt.setSwapInterval(1);
fmt.setDepthBufferSize(16);
if (apiOpenGLES3)
{
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setVersion(3, 2);
}
else
{
fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
fmt.setVersion(2, 1);
}
auto surface = std::make_unique<QOffscreenSurface>();
surface->setFormat(fmt);
surface->create();
auto context = std::make_unique<QOpenGLContext>();
context->setFormat(fmt);
context->create();
context->makeCurrent(surface.get());
if (fn)
fn(apiOpenGLES3);
context->doneCurrent();
surface->destroy();
QTimer::singleShot(0, &app, SLOT(quit()));
app.exec();
}
示例3: QMenu
OpenGLWidget::OpenGLWidget(MainWindow* mainWindow)
: QOpenGLWidget{mainWindow}
, m_axisLegendScene{mainWindow->app()}
, m_width{0}
, m_height{0}
, m_currentLocation{}
, m_previousLocation{}
{
this->setFocusPolicy(Qt::StrongFocus);
m_contextMenu = new QMenu(this);
QMenu* createMenu = m_contextMenu->addMenu("Create");
createMenu->addAction(tr("Box"), this, SLOT(createBox()));
createMenu->addAction(tr("Cylinder"), this, SLOT(createCylinder()));
createMenu->addAction(tr("Cone"), this, SLOT(createCone()));
createMenu->addAction(tr("Sphere"), this, SLOT(createSphere()));
m_contextMenu->addAction(tr("Import Mesh"), this, SLOT(importMesh()));
QSurfaceFormat format = this->format();
format.setVersion(kOpenGLMajorVersion, kOpenGLMinorVersion);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setDepthBufferSize(32);
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
LOG(INFO) << fmt::format("Setting format with OpenGL version {}.{}", kOpenGLMajorVersion, kOpenGLMinorVersion);
this->setFormat(format);
}
示例4: QMainWindow
MainWindow::MainWindow
(
QWidget * parent
):
QMainWindow(parent),
m_ui(new Ui::MainWindow)
{
m_ui->setupUi(this);
// Setup OpenGL context format
QSurfaceFormat format;
#ifdef __APPLE__
// Get OpenGL 3.2/4.1 core context
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
#else
// Get newest available compatibility context
#endif
format.setDepthBufferSize(16);
// Create OpenGL context and window
m_canvas.reset(new gloperate_qt::QtOpenGLWindowBase(format));
// Create widget container
setCentralWidget(QWidget::createWindowContainer(m_canvas.get()));
centralWidget()->setFocusPolicy(Qt::StrongFocus);
}
示例5: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QApplication::setApplicationName("Editor");
QApplication::setApplicationVersion("1.0");
#if C3_OS == C3_OS_WINDOWS_NT
//Windows native theme looks so ugly
app.setStyle("fusion");
#endif
QCommandLineParser parser;
parser.setApplicationDescription("The Editor");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption dataDirOption("root",
"Root directory location.\nThis will override ENGINE_ROOT.",
"path");
parser.addOption(dataDirOption);
parser.process(app);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString absPath;
if(!parser.value(dataDirOption).isEmpty())
{
absPath = parser.value(dataDirOption);
}
else if(env.contains("ENGINE_ROOT"))
absPath = env.value("ENGINE_ROOT");
else
absPath = ".";
QFileInfo dirInfo(absPath);
if(!dirInfo.exists() || !dirInfo.isDir() || !QFileInfo::exists(absPath + "/Data"))
{
const char* msg = "Invalid root directory!";
QMessageBox::critical(nullptr, app.applicationName(), msg);
throw msg;
}
absPath = dirInfo.canonicalFilePath();
EngineLoader.SetRootDirectory(absPath.toUtf8().constData());
c3::RC.Loader = &EngineLoader;
c3::RC.Loader->InitEngine();
c3::FEditor EditorController;
c3::RC.Editor = &EditorController;
QSurfaceFormat format;
format.setVersion(4, 5);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
QSurfaceFormat::setDefaultFormat(format);
MainWindow mainWindow;
c3::FLogDisplay* LogDisplay = static_cast<c3::FLogDisplay*>(EditorController.GetLogDisplay());
QObject::connect(LogDisplay, &c3::FLogDisplay::LogRefreshed,
&mainWindow, &MainWindow::OnLogChanged);
mainWindow.showMaximized();
app.exec();
}
示例6: main
int main(int argc, char *argv[])
{
qputenv("PATH", qgetenv("PATH") + ":/usr/local/bin:/usr/bin");
QApplication a(argc, argv);
QSplashScreen s(QPixmap(":/application/splash"), Qt::WindowStaysOnTopHint);
s.show();
QApplication::setOrganizationName("Regulomics");
QApplication::setApplicationName("QChromosome 4D Studio");
QApplication::setWindowIcon(QIcon(":/application/icon"));
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setVersion(4, 1);
format.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(format);
QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular");
QFontDatabase::addApplicationFont(":/fonts/Roboto-Bold");
QFontDatabase::addApplicationFont(":/fonts/RobotoMono-Regular");
MainWindow w(a.arguments().mid(1));
a.installEventFilter(&w);
w.showMaximized();
s.finish(&w);
return a.exec();
}
示例7: main
int main(int argc, char* argv[])
{
QGuiApplication app(argc,argv);
qmlRegisterType<Connector>("Connector", 1, 0, "Connector");
app.setOrganizationName("QtProject");\
app.setOrganizationDomain("qt-project.org");\
app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());\
QQuickView view;\
if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
QSurfaceFormat f = view.format();\
f.setProfile(QSurfaceFormat::CoreProfile);\
f.setVersion(4, 4);\
view.setFormat(f);\
}\
view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));\
new QQmlFileSelector(view.engine(), &view);\
view.setSource(QUrl("qrc:///demos/tweetsearch/tweetsearch.qml")); \
view.setResizeMode(QQuickView::SizeRootObjectToView);\
if (QGuiApplication::platformName() == QLatin1String("qnx") || \
QGuiApplication::platformName() == QLatin1String("eglfs")) {\
view.showFullScreen();\
} else {\
view.show();\
}\
return app.exec();\
}
示例8: main
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";
}
示例9: QQmlFileSelector
EffectsManager::EffectsManager(QObject *parent) : QObject(parent), QQuickImageProvider(QQuickImageProvider::Image)
{
if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
QSurfaceFormat f = view.format();\
f.setProfile(QSurfaceFormat::CoreProfile);\
f.setVersion(4, 4);\
view.setFormat(f);\
}\
// view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
new QQmlFileSelector(view.engine(), &view);
view.engine()->rootContext()->setContextProperty("effectsControll", this);
//view.engine()->addImageProvider("loader", cloneImg);
view.setSource(QUrl("qrc:/mainEffectWindow.qml")); \
view.setResizeMode(QQuickView::SizeRootObjectToView);
// view.setPersistentOpenGLContext(true);
view.setColor("transparent");
//addEffect("first",100,100);
/* QStringList dataList;
dataList.append("Item 1");
QQmlContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));*/
//viewsetFont(QFont("Segoe Script"));
/*
QSize t_size(300,300);
view.setMaximumSize(t_size);
view.setMinimumSize(t_size);
*/
}
示例10: main
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();
w.sendItems();
return a.exec();
}
示例11: main
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();
}
示例12: main
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());
}
示例13: setupCanvas
void Viewer::setupCanvas()
{
QSurfaceFormat format;
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setDepthBufferSize(16);
// Create OpenGL context and window
m_canvas.reset(new gloperate_qt::QtOpenGLWindow(*m_resourceManager, format));
// Create widget container
setCentralWidget(QWidget::createWindowContainer(m_canvas.get()));
centralWidget()->setFocusPolicy(Qt::StrongFocus);
// Setup event provider to translate Qt messages into gloperate events
gloperate_qt::QtKeyEventProvider * keyProvider = new gloperate_qt::QtKeyEventProvider();
keyProvider->setParent(m_canvas.get());
gloperate_qt::QtMouseEventProvider * mouseProvider = new gloperate_qt::QtMouseEventProvider();
mouseProvider->setParent(m_canvas.get());
gloperate_qt::QtWheelEventProvider * wheelProvider = new gloperate_qt::QtWheelEventProvider();
wheelProvider->setParent(m_canvas.get());
m_canvas->installEventFilter(keyProvider);
m_canvas->installEventFilter(mouseProvider);
m_canvas->installEventFilter(wheelProvider);
// Create input mapping for gloperate interaction techniques
m_mapping.reset(new QtViewerMapping(m_canvas.get()));
m_mapping->addProvider(keyProvider);
m_mapping->addProvider(mouseProvider);
m_mapping->addProvider(wheelProvider);
}
示例14: main
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QVRManager manager(argc, argv);
/* Load the model file */
if (argc != 2) {
std::cerr << argv[0] << ": requires model filename argument." << std::endl;
return 1;
}
osg::ref_ptr<osgDB::ReaderWriter::Options> options = new osgDB::ReaderWriter::Options();
options->setOptionString("noRotation");
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(argv[1], options);
if (!model) {
std::cerr << argv[0] << ": no data loaded." << std::endl;
return 1;
}
/* First set the default surface format that all windows will use */
QSurfaceFormat format;
format.setProfile(QSurfaceFormat::CompatibilityProfile); // OSG cannot handle core profiles
format.setVersion(3, 3);
QSurfaceFormat::setDefaultFormat(format);
/* Then start QVR with your app */
QVROSGViewer qvrapp(model);
if (!manager.init(&qvrapp)) {
std::cerr << "Cannot initialize QVR manager" << std::endl;
return 1;
}
/* Enter the standard Qt loop */
return app.exec();
}
示例15: setup
void GLViewer::setup()
{
QSurfaceFormat format;
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setDepthBufferSize(16);
m_canvas = new Canvas(format);
m_canvas->setContinuousRepaint(true, 0);
m_canvas->setSwapInterval(Canvas::VerticalSyncronization);
m_canvas->setPainter(m_painter);
QWidget *widget = QWidget::createWindowContainer(m_canvas);
widget->setMinimumSize(1, 1);
widget->setAutoFillBackground(false); // Important for overdraw, not occluding the scene.
widget->setFocusPolicy(Qt::TabFocus);
widget->setParent(this);
QHBoxLayout *layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(widget);
setLayout(layout);
show();
}