本文整理汇总了C++中QSurfaceFormat::setMajorVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat::setMajorVersion方法的具体用法?C++ QSurfaceFormat::setMajorVersion怎么用?C++ QSurfaceFormat::setMajorVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSurfaceFormat
的用法示例。
在下文中一共展示了QSurfaceFormat::setMajorVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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(5);
#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);
// set this as the default format for all windows
QSurfaceFormat::setDefaultFormat(format);
// now we are going to create our scene window
NGLScene 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();
}
示例3: QWindow
yage::GLWindow::GLWindow(QScreen *screen)
: QWindow(screen)
, m_context(0)
{
// Tell Qt we will use OpenGL for this window
setSurfaceType( OpenGLSurface );
QSurfaceFormat format;
format.setDepthBufferSize( 24 );
format.setMajorVersion( 3 );
format.setMinorVersion( 2 );
format.setSamples( 4 );
format.setProfile( QSurfaceFormat::CoreProfile );
setFormat( format );
}
示例4: main
int main(int argc, char *argv[])
{
QSurfaceFormat format;
format.setMajorVersion( 4 );
format.setMinorVersion( 1 );
format.setProfile( QSurfaceFormat::CoreProfile );
QSurfaceFormat::setDefaultFormat(format);
QApplication a(argc, argv);
MainWindow m;
m.show();
return a.exec();
}
示例5: QWindow
/**
* @brief Constructeur paramétré
*
* Permet d'initialiser la fenêtre et les propriétés de la zone de rendu OpenGL
*
* @param screen Propriétés de l'écran
*/
Window::Window(QScreen *screen)
: QWindow(screen),
m_scene(new MovingColoredTriangle(this))
{
// On définit le type de la zone de rendu, dans notre cas il
// s'agit d'une zone OpenGL
setSurfaceType(QSurface::OpenGLSurface);
// Puis on définit les propriétés de la zone de rendu
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setMajorVersion(4);
format.setMinorVersion(3);
format.setSamples(4); // Multisampling x4
format.setProfile(QSurfaceFormat::CoreProfile); // Fonctions obsolètes d'OpenGL non disponibles
format.setOption(QSurfaceFormat::DebugContext);
// On applique le format et on créer la fenêtre
setFormat(format);
create();
resize(800, 600);
setTitle("OpenGLSBExamplesQt - MovingColoredTriangle");
// On créer le contexte OpenGL et on définit son format
m_context = new QOpenGLContext;
m_context->setFormat(format);
m_context->create();
m_context->makeCurrent(this);
// On définit le contexte OpenGL de la scène
m_scene->setContext(m_context);
m_timer.start();
initializeGL();
connect(this, SIGNAL(widthChanged(int)), this, SLOT(resizeGL()));
connect(this, SIGNAL(heightChanged(int)), this, SLOT(resizeGL()));
resizeGL();
// Création d'un timer permettant la mise à jour de la zone de rendu 60 fois par seconde
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateScene()));
timer->start(16); // f = 1 / 16.10e-3 = 60Hz
}
示例6: versionCheck
void tst_QSurfaceFormat::versionCheck()
{
QFETCH( int, formatMajor );
QFETCH( int, formatMinor );
QFETCH( int, compareMajor );
QFETCH( int, compareMinor );
QFETCH( bool, expected );
QSurfaceFormat format;
format.setMinorVersion(formatMinor);
format.setMajorVersion(formatMajor);
QCOMPARE(format.version() >= qMakePair(compareMajor, compareMinor), expected);
format.setVersion(formatMajor, formatMinor);
QCOMPARE(format.version() >= qMakePair(compareMajor, compareMinor), expected);
}
示例7: currentTimeMs
MyWindow::MyWindow() : currentTimeMs(0), currentTimeS(0)
{
mProgram = 0;
setSurfaceType(QWindow::OpenGLSurface);
setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setMajorVersion(4);
format.setMinorVersion(3);
format.setSamples(4);
format.setProfile(QSurfaceFormat::CoreProfile);
setFormat(format);
create();
resize(800, 600);
mContext = new QOpenGLContext(this);
mContext->setFormat(format);
mContext->create();
mContext->makeCurrent( this );
mFuncs = mContext->versionFunctions<QOpenGLFunctions_4_3_Core>();
if ( !mFuncs )
{
qWarning( "Could not obtain OpenGL versions object" );
exit( 1 );
}
if (mFuncs->initializeOpenGLFunctions() == GL_FALSE)
{
qWarning( "Could not initialize core open GL functions" );
exit( 1 );
}
initializeOpenGLFunctions();
QTimer *repaintTimer = new QTimer(this);
connect(repaintTimer, &QTimer::timeout, this, &MyWindow::render);
repaintTimer->start(1000/60);
QTimer *elapsedTimer = new QTimer(this);
connect(elapsedTimer, &QTimer::timeout, this, &MyWindow::modCurTime);
elapsedTimer->start(1);
}
示例8: main
int main(int argc, char *argv[])
{
OVR::System::Init();
qmlRegisterType<FileIO>("FileIO", 1, 0, "FileIO");
qmlRegisterType<StereoViewport>("StereoViewport", 1, 0, "StereoViewport");
qmlRegisterType<OculusReader>("OculusReader", 1, 0, "OculusReader");
qmlRegisterType<FrameRateCounter>("OculusReader", 1, 0, "FrameRateCounter");
qmlRegisterType<MDStateManager>("MDStateManager", 1, 0, "MDStateManager");
qmlRegisterType<Settings>("Settings", 1, 0, "Settings");
qmlRegisterType<ScreenInfo>("ScreenInfo", 1, 0, "ScreenInfo");
qmlRegisterType<ScreenInfoScreen>("ScreenInfo", 1, 0, "ScreenInfoScreen");
qmlRegisterType<MultiBillboard>("CompPhys.MultiBillboard", 1, 0, "MultiBillboard");
qmlRegisterType<DataSource>("CompPhys.MultiBillboard", 1, 0, "DataSource");
qmlRegisterType<MouseMover>("CompPhys.FlyModeNavigator", 1, 0, "MouseMover");
QGuiApplication app(argc, argv);
QSurfaceFormat format;
format.setMajorVersion(4);
format.setMinorVersion(3);
OculusView view;
view.setFormat(format);
#ifdef Q_OS_MACX
view.addImportPath(".");
#else
view.addImportPath("../libs");
#endif
#ifdef Q_OS_LINUX
// view.engine()->addImportPath("/home/compphys/sandbox/flymodenavigator-qt3d/build-flymodenavigator-Desktop_Qt_5_2_0_GCC_64bit-Release/src/libs");
#else
// view.engine()->addImportPath("/repos/flymodenavigator-qt3d/build-flymodenavigator-Desktop_Qt_5_2_0_clang_64bit-Release/src/libs");
#endif
view.setMainQmlFile("../qml/oculus/main.qml");
// view.fullScreenAllMonitors();
view.show();
setlocale (LC_ALL, "en_US.UTF8");
return app.exec();
}
示例9: 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();
}
示例10: QWindow
OpenGLWindow::OpenGLWindow(QWindow *parent)
: QWindow(parent)
, m_update_pending(false)
, m_animating(false)
, m_context(0)
, m_device(0)
, m_frames(0)
, m_fps(0)
{
setSurfaceType(QWindow::OpenGLSurface);
QSurfaceFormat format;
format.setSamples(4); // multi-sampling
format.setRenderableType(QSurfaceFormat::OpenGL); // change to opengles on mobile
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setMajorVersion(3);
format.setMinorVersion(2);
format.setDepthBufferSize(24);
setFormat(format);
// Hide the cursor since this is a fullscreen app
setCursor(Qt::BlankCursor);
}
示例11: QOpenGLContext
window::window(init_fn_type const& init_fn,
step_fn_type const& step_fn,
draw_fn_type const& draw_fn,
fini_fn_type const& fini_fn)
: m_context(nullptr)
, m_gl_logger(nullptr)
, m_initialised(false)
, m_finished(false)
, m_init_fn(init_fn)
, m_step_fn(step_fn)
, m_draw_fn(draw_fn)
, m_fini_fn(fini_fn)
{
QSurfaceFormat format;
// format.setDepthBufferSize(16);
format.setDepthBufferSize( 24 );
format.setMajorVersion(4U);
format.setMinorVersion(2U);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
format.setOption(QSurfaceFormat::DebugContext);
format.setSwapInterval(0);
format.setSamples(0);
m_context = new QOpenGLContext(this);
m_context->setFormat(format);
m_context->create();
setSurfaceType(QWindow::OpenGLSurface);
setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
//setGeometry(QRect(10, 10, 640, 480));
setFormat(format);
create();
}
示例12: toSurfaceFormat
/*!
Returns a window format for the OpenGL format specified by \a format.
*/
QSurfaceFormat QGLFormat::toSurfaceFormat(const QGLFormat &format)
{
QSurfaceFormat retFormat;
if (format.alpha())
retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize());
if (format.blueBufferSize() >= 0)
retFormat.setBlueBufferSize(format.blueBufferSize());
if (format.greenBufferSize() >= 0)
retFormat.setGreenBufferSize(format.greenBufferSize());
if (format.redBufferSize() >= 0)
retFormat.setRedBufferSize(format.redBufferSize());
if (format.depth())
retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize());
retFormat.setSwapBehavior(format.doubleBuffer() ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::DefaultSwapBehavior);
if (format.sampleBuffers())
retFormat.setSamples(format.samples() == -1 ? 4 : format.samples());
if (format.stencil())
retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize());
retFormat.setStereo(format.stereo());
retFormat.setMajorVersion(format.majorVersion());
retFormat.setMinorVersion(format.minorVersion());
retFormat.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>(format.profile()));
return retFormat;
}
示例13: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSurfaceFormat format;
format.setMajorVersion(4);
format.setMinorVersion(1);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
format.setSamples(2);
format.setDepthBufferSize(24);
format.setRedBufferSize(8);
format.setGreenBufferSize(8);
format.setBlueBufferSize(8);
format.setAlphaBufferSize(0);
format.setStencilBufferSize(8);
QSurfaceFormat::setDefaultFormat(format);
DemoGLWindow window;
window.show();
return a.exec();
}
示例14: QQuickView
Window::Window()
: QQuickView()
, m_terrain(nullptr)
, m_mouseDown(false)
, m_speed(0.01)
, m_needsUpdate(true)
, m_generate(false)
, m_paused(false)
, m_curTimeId(0)
{
updateUi();
rootContext()->setContextProperty("Game", this);
setSurfaceType(QWindow::OpenGLSurface);
setClearBeforeRendering(false);
setPersistentOpenGLContext(true);
setResizeMode(QQuickView::SizeRootObjectToView);
setSource(QUrl::fromLocalFile(FileFinder::findFile(FileFinder::Type::Qml, "ui.qml")));
QSurfaceFormat format = requestedFormat();
format.setProfile(QSurfaceFormat::CoreProfile);
format.setMajorVersion(3);
format.setMinorVersion(3);
format.setDepthBufferSize(24);
format.setOption(QSurfaceFormat::DebugContext);
setFormat(format);
resize(1024, 768);
connect(this, &QQuickWindow::beforeRendering, this, &Window::renderNow, Qt::DirectConnection);
connect(this, &QQuickWindow::beforeSynchronizing, this, &Window::sync, Qt::DirectConnection);
connect(this, &QQuickWindow::afterRendering, this, &Window::updateUi);
connect(this, &QQuickWindow::afterRendering, this, &Window::update);
show();
}
示例15: main
int main(int argc, char *argv[])
{
try
{
for (int n = 1; n < argc; n++) {
if (strcmp(argv[n], "--licenses") == 0) {
QFile licenses(":/misc/licenses.txt");
licenses.open(QIODevice::ReadOnly | QIODevice::Text);
QByteArray contents = licenses.readAll();
printf("%.*s\n", (int)contents.size(), contents.data());
return 0;
}
}
int newArgc = argc;
char **newArgv = appendCommandLineArguments(&newArgc, argv);
// Supress SSL related warnings on OSX
// See https://bugreports.qt.io/browse/QTBUG-43173 for more info
//
#ifdef Q_OS_MAC
qputenv("QT_LOGGING_RULES", "qt.network.ssl.warning=false");
// Request OpenGL 4.1 if possible on OSX, otherwise it defaults to 2.0
// This needs to be done before we create the QGuiApplication
//
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setMajorVersion(3);
format.setMinorVersion(2);
format.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(format);
#endif
QGuiApplication app(newArgc, newArgv);
initQt(&app);
// init breakpad.
setupCrashDumper();
UniqueApplication* uniqueApp = new UniqueApplication();
if (!uniqueApp->ensureUnique())
return EXIT_SUCCESS;
#ifdef Q_OS_UNIX
// install signals handlers for proper app closing.
SignalManager signalManager(&app);
Q_UNUSED(signalManager);
#endif
initLogger();
QLOG_INFO() << "Starting Plex Media Player version:" << qPrintable(Version::GetVersionString()) << "build date:" << qPrintable(Version::GetBuildDate());
QLOG_INFO() << qPrintable(QString(" Running on: %1 [%2] arch %3").arg(QSysInfo::prettyProductName()).arg(QSysInfo::kernelVersion()).arg(QSysInfo::currentCpuArchitecture()));
QLOG_INFO() << " Qt Version:" << QT_VERSION_STR << qPrintable(QString("[%1]").arg(QSysInfo::buildAbi()));
// Quit app and apply update if we find one.
if (UpdateManager::CheckForUpdates())
{
app.quit();
return 0;
}
#ifdef Q_OS_WIN32
initD3DDevice();
#endif
#ifdef Q_OS_UNIX
setlocale(LC_NUMERIC, "C");
#endif
// Initialize all the components. This needs to be done
// early since most everything else relies on it
//
ComponentManager::Get().initialize();
// enable remote inspection if we have the correct setting for it.
if (SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "remoteInspector").toBool())
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "0.0.0.0:9992");
QtWebEngine::initialize();
// Qt and QWebEngineProfile set the locale, which breaks parsing and
// formatting float numbers in a few countries.
#ifdef Q_OS_UNIX
setlocale(LC_NUMERIC, "C");
#endif
// start our helper
HelperLauncher::Get().connectToHelper();
// load QtWebChannel so that we can register our components with it.
QQmlApplicationEngine *engine = KonvergoEngine::Get();
KonvergoWindow::RegisterClass();
engine->rootContext()->setContextProperty("components", &ComponentManager::Get().getQmlPropertyMap());
// This controls how big the web view will zoom using semantic zoom
// over a specific number of pixels and we run out of space for on screen
// tiles in chromium. This only happens on OSX since on other platforms
// we can use the GPU to transfer tiles directly but we set the limit on all platforms
// to keep it consistent.
//
//.........这里部分代码省略.........