本文整理汇总了C++中QSurfaceFormat::setMinorVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat::setMinorVersion方法的具体用法?C++ QSurfaceFormat::setMinorVersion怎么用?C++ QSurfaceFormat::setMinorVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSurfaceFormat
的用法示例。
在下文中一共展示了QSurfaceFormat::setMinorVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
QGuiApplication app(argc, argv);
Q_UNUSED(app);
QSurfaceFormat format;
format.setMajorVersion(3);
format.setMinorVersion(0);
QOpenGLContext context;
context.setFormat(format);
context.create();
if (!context.isValid()) return 1;
qDebug() << QString::fromLatin1("Context created.");
QOffscreenSurface surface;
surface.setFormat(format);
surface.create();
if(!surface.isValid()) return 2;
qDebug() << QString::fromLatin1("Surface created.");
context.makeCurrent(&surface);
return RUN_ALL_TESTS();
}
示例2: main
int main( int argc, char* argv[] )
{
QGuiApplication a( argc, argv );
QStringList args = a.arguments();
if ( args.size() != 2 )
{
qDebug() << "Please specify an obj file to load";
exit( 1 );
}
const QString fileName = args.last();
// Specify the format we wish to use
QSurfaceFormat format;
format.setMajorVersion( 3 );
#if !defined(Q_OS_MAC)
format.setMinorVersion( 3 );
#else
format.setMinorVersion( 2 );
#endif
format.setDepthBufferSize( 24 );
format.setSamples( 4 );
format.setProfile( QSurfaceFormat::CoreProfile );
OpenGLWindow w( format );
w.setScene( new MultipleLightsScene( fileName ) );
w.show();
return a.exec();
}
示例3: d
QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
: d(new QGLTemporaryContextPrivate)
{
d->oldContext = const_cast<QGLContext *>(QGLContext::currentContext());
d->window = new QWindow;
d->window->setSurfaceType(QWindow::OpenGLSurface);
d->window->setGeometry(QRect(0, 0, 3, 3));
d->window->create();
d->context = new QOpenGLContext;
#if !defined(QT_OPENGL_ES)
// On desktop, request latest released version
QSurfaceFormat format;
#if defined(Q_OS_MAC)
// OS X is limited to OpenGL 3.2 Core Profile at present
// so set that here. If we use compatibility profile it
// only reports 2.x contexts.
format.setMajorVersion(3);
format.setMinorVersion(2);
format.setProfile(QSurfaceFormat::CoreProfile);
#else
format.setMajorVersion(4);
format.setMinorVersion(3);
#endif
d->context->setFormat(format);
#endif
d->context->create();
d->context->makeCurrent(d->window);
}
示例4: 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(3);
#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);
// now we are going to create our scene window
NGLScene window;
// and set the OpenGL format
window.setFormat(format);
// we can now query the version to see if it worked
std::cout<<"Profile is "<<format.majorVersion()<<" "<<format.minorVersion()<<"\n";
// set the window size
// and finally show
window.show();
window.resize(1024, 720);
return app.exec();
}
示例5: main
int main(int argc, char **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( DARWIN)
// 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(2);
#else
// with luck we have the latest GL version so set to this
format.setMajorVersion(4);
format.setMinorVersion(3);
#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);
// this will set the format for all widgets
QSurfaceFormat::setDefaultFormat(format);
// make an instance of the QApplication
CebApplication a(argc, argv);
// Create a new MainWindow
MainWindow w;
// show main window
w.show();
// show start dialog
w.showStartDialog();
// hand control over to Qt framework
return a.exec();
}
示例6: QWindow
GLWindow::GLWindow(QScreen *screen) : QWindow(screen) {
QSurfaceFormat cformat;
cformat.setDepthBufferSize(24);
cformat.setMajorVersion(4);
cformat.setMinorVersion(2);
cformat.setProfile(QSurfaceFormat::CoreProfile);
resize(800,600);
setSurfaceType(OpenGLSurface);
create();
_context = new QOpenGLContext;
_context->setFormat(cformat);
_context->create();
connect(this,SIGNAL(widthChanged(int)), this, SLOT(resizeGL()));
connect(this,SIGNAL(heightChanged(int)), this, SLOT(resizeGL()));
initializeGL();
resizeGL();
/*QTimer* timer = new QTimer(this);
connect( timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start();*/
}
示例7: getDefaultOpenGLSurfaceFormat
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
static QSurfaceFormat format;
static std::once_flag once;
std::call_once(once, [] {
#if defined(USE_GLES)
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setRedBufferSize(8);
format.setGreenBufferSize(8);
format.setBlueBufferSize(8);
format.setAlphaBufferSize(8);
#else
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
#endif
if (gl::Context::enableDebugLogger()) {
format.setOption(QSurfaceFormat::DebugContext);
}
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS);
format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS);
int major, minor;
::gl::getTargetVersion(major, minor);
format.setMajorVersion(major);
format.setMinorVersion(minor);
});
return format;
}
示例8: QWindow
Window::Window(QScreen *screen) :
QWindow (screen),
scene_ (new BasicUsageScene)
{
setSurfaceType(OpenGLSurface);
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setMajorVersion(3);
format.setMinorVersion(3);
format.setSamples(4);
format.setProfile(QSurfaceFormat::CoreProfile);
resize(800, 600);
setFormat(format);
create();
context_ = new QOpenGLContext();
context_->setFormat(format);
context_->create();
scene_->setContext(context_);
initializeGl();
connect(this, SIGNAL(widthChanged(int)), this, SLOT(resizeGl()));
connect(this, SIGNAL(heightChanged(int)), this, SLOT(resizeGl()));
resizeGl();
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateScene()));
timer->start(16);
}
示例9: 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);
format.setMajorVersion(3);
format.setMinorVersion(2);
// now we are going to set to Compat Profile OpenGL so we can use and old Immediate mode GL
format.setProfile(QSurfaceFormat::CompatibilityProfile);
// now set the depth buffer to 24 bits
format.setDepthBufferSize(24);
QSurfaceFormat::setDefaultFormat(format);
// now we are going to create our scene window
OpenGLWindow 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();
}
示例10: QOpenGLWidget
RenderWidget::RenderWidget(QWidget *parent) :
QOpenGLWidget(parent),
renderFunctions(nullptr),
render(nullptr),
quad(nullptr),
quadShader(nullptr),
openglDebugLogger(nullptr),
captureMouse(false),
onlyShowTexture(false),
textureDisplayed(color)
{
// Widget config
setUpdateBehavior(QOpenGLWidget::NoPartialUpdate);
setFocusPolicy(Qt::ClickFocus);
// Update Timer config
connect(&updateTimer, SIGNAL(timeout()), this, SLOT(update()));
startUpdateLoop();
// Open GL Context config
QSurfaceFormat f;
f.setRenderableType(QSurfaceFormat::OpenGL);
f.setMajorVersion(4);
f.setMinorVersion(5);
f.setProfile(QSurfaceFormat::CoreProfile);
f.setOptions(QSurfaceFormat::DebugContext | f.options());
setFormat(f);
}
示例11: reserved
ContextPoolContext::ContextPoolContext(QOpenGLContext* share_context, bool reserved)
: reserved(reserved), count(0), surface(NULL), context(NULL)
{
QSurfaceFormat format;
format.setMajorVersion(3);
format.setMinorVersion(2);
format.setSwapInterval(0);
format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
surface = new QOffscreenSurface();
surface->setFormat(format);
surface->create();
if (!surface->isValid()) {
throw;
}
context = new QOpenGLContext();
context->setShareContext(share_context);
context->setFormat(surface->requestedFormat());
if (!context->create()) {
throw;
}
context->makeCurrent(surface);
gl = context->versionFunctions<QOpenGLFunctions_3_2_Core>();
if (gl == nullptr || !gl->initializeOpenGLFunctions()) {
throw;
}
indirect = new QOpenGLExtension_ARB_multi_draw_indirect();
if (!indirect->initializeOpenGLFunctions()) {
throw;
}
vab = new QOpenGLExtension_ARB_vertex_attrib_binding();
if (!vab->initializeOpenGLFunctions()) {
throw;
}
sso = new QOpenGLExtension_ARB_separate_shader_objects();
if (!sso->initializeOpenGLFunctions()) {
throw;
}
tex = new QOpenGLExtension_ARB_texture_buffer_object();
if (!tex->initializeOpenGLFunctions()) {
throw;
}
buffer = (QOpenGLExtension_ARB_buffer_storage)context->getProcAddress("glBufferStorage");
debug = new QOpenGLExtension_ARB_debug_output();
if (!debug->initializeOpenGLFunctions()) {
throw;
}
debug->glDebugMessageCallbackARB(debug_callback, nullptr);
debug->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_FALSE);
debug->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, 0, GL_TRUE);
context->doneCurrent();
context->moveToThread(nullptr);
}
示例12: controlContext
void HsQMLContextControl::controlContext()
{
// Do nothing if no window
if (!mWindow) {
return;
}
// Do nothing if changes are being deferred
if (mDefer || !mWhen) {
mPending = true;
return;
}
mPending = false;
QSurfaceFormat fmt = mOriginal;
if (mMajorVersion >= 0) {
fmt.setMajorVersion(mMajorVersion);
}
if (mMinorVersion >= 0) {
fmt.setMinorVersion(mMinorVersion);
}
if (mContextType >= 0) {
fmt.setRenderableType(static_cast<QSurfaceFormat::RenderableType>(
mContextType));
}
if (mContextProfile >= 0) {
fmt.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>(
mContextProfile));
}
if (mDeprecatedFunctionsSet) {
#if QT_VERSION >= 0x050300
fmt.setOption(QSurfaceFormat::DeprecatedFunctions,
mDeprecatedFunctions);
#else
if (mDeprecatedFunctions) {
fmt.setOption(QSurfaceFormat::DeprecatedFunctions);
}
#endif
}
fmt.setDepthBufferSize(qMax(fmt.depthBufferSize(), mDepthBufferSize));
fmt.setStencilBufferSize(qMax(fmt.stencilBufferSize(), mStencilBufferSize));
if (fmt == mWindow->requestedFormat()) {
return;
}
mWindow->setFormat(fmt);
// Recreate OpenGL context
mWindow->setPersistentOpenGLContext(false);
mWindow->setPersistentSceneGraph(false);
bool visible = mWindow->isVisible();
mWindow->destroy();
mWindow->releaseResources();
mWindow->setVisible(visible);
mWindow->setPersistentOpenGLContext(true);
mWindow->setPersistentSceneGraph(true);
}
示例13: Init
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool COpenVROverlayController::Init()
{
bool bSuccess = true;
m_strName = "Alerts";
QSurfaceFormat format;
format.setMajorVersion( 4 );
format.setMinorVersion( 1 );
format.setProfile( QSurfaceFormat::CompatibilityProfile );
m_pOpenGLContext = new QOpenGLContext();
m_pOpenGLContext->setFormat( format );
bSuccess = m_pOpenGLContext->create();
if( !bSuccess )
return false;
// create an offscreen surface to attach the context and FBO to
m_pOffscreenSurface = new QOffscreenSurface();
m_pOffscreenSurface->create();
m_pOpenGLContext->makeCurrent( m_pOffscreenSurface );
m_pScene = new QGraphicsScene();
connect( m_pScene, SIGNAL(changed(const QList<QRectF>&)), this, SLOT( OnSceneChanged(const QList<QRectF>&)) );
// Loading the OpenVR Runtime
bSuccess = ConnectToVRRuntime();
bSuccess = bSuccess && vr::VRCompositor() != NULL;
if( vr::VROverlay() )
{
std::string sKey = "texasgamer.openvr-notifications.overlay.Alerts";
vr::VROverlayError overlayError = vr::VROverlay()->CreateDashboardOverlay(sKey.c_str(), "Alerts", &m_ulOverlayHandle, &m_ulOverlayThumbnailHandle);
QString name = qApp->applicationDirPath() + "/resources/overlay-icon.png";
vr::VROverlay()->SetOverlayFromFile(m_ulOverlayThumbnailHandle, name.toUtf8().constData());
bSuccess = bSuccess && overlayError == vr::VROverlayError_None;
}
if( bSuccess )
{
vr::VROverlay()->SetOverlayWidthInMeters( m_ulOverlayHandle, 1.5f );
vr::VROverlay()->SetOverlayInputMethod( m_ulOverlayHandle, vr::VROverlayInputMethod_Mouse );
m_pPumpEventsTimer = new QTimer( this );
connect(m_pPumpEventsTimer, SIGNAL( timeout() ), this, SLOT( OnTimeoutPumpEvents() ) );
m_pPumpEventsTimer->setInterval( 20 );
m_pPumpEventsTimer->start();
qInfo() << "Connected with OpenVR.";
} else {
qInfo() << "Unable to start openvr-notifications. Unable to connect with OpenVR.";
}
return true;
}
示例14: 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();
}
示例15: 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();
}