当前位置: 首页>>代码示例>>C++>>正文


C++ QSurfaceFormat::minorVersion方法代码示例

本文整理汇总了C++中QSurfaceFormat::minorVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat::minorVersion方法的具体用法?C++ QSurfaceFormat::minorVersion怎么用?C++ QSurfaceFormat::minorVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSurfaceFormat的用法示例。


在下文中一共展示了QSurfaceFormat::minorVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createContext

static HGLRC createContext(const QOpenGLStaticContext &staticContext,
                           HDC hdc,
                           const QSurfaceFormat &format,
                           const QWindowsOpenGLAdditionalFormat &,
                           HGLRC shared = 0)
{
    enum { attribSize = 11 };

    if (!staticContext.hasExtensions())
        return 0;
    int attributes[attribSize];
    int attribIndex = 0;
    qFill(attributes, attributes + attribSize, int(0));
    const int requestedVersion = (format.majorVersion() << 8) + format.minorVersion();
    if (requestedVersion > 0x0101) {
        attributes[attribIndex++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
        attributes[attribIndex++] = format.majorVersion();
        attributes[attribIndex++] = WGL_CONTEXT_MINOR_VERSION_ARB;
        attributes[attribIndex++] = format.minorVersion();
    }
    if (requestedVersion >= 0x0300) {
        attributes[attribIndex++] = WGL_CONTEXT_FLAGS_ARB;
        attributes[attribIndex] = 0;
        if (format.testOption(QSurfaceFormat::DeprecatedFunctions))
             attributes[attribIndex] |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
        if (format.testOption(QSurfaceFormat::DebugContext))
            attributes[attribIndex++] |= WGL_CONTEXT_DEBUG_BIT_ARB;
        attribIndex++;
    }
    if (requestedVersion >= 0x0302) {
        switch (format.profile()) {
        case QSurfaceFormat::NoProfile:
            break;
        case QSurfaceFormat::CoreProfile:
            attributes[attribIndex++] = WGL_CONTEXT_PROFILE_MASK_ARB;
            attributes[attribIndex++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
            break;
        case QSurfaceFormat::CompatibilityProfile:
            attributes[attribIndex++] = WGL_CONTEXT_PROFILE_MASK_ARB;
            attributes[attribIndex++] = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
            break;
        }
    }
    if (QWindowsContext::verboseGL)
        qDebug("%s: Creating context version %d.%d with %d attributes",
               __FUNCTION__,  format.majorVersion(), format.minorVersion(), attribIndex / 2);

    const HGLRC result =
        staticContext.wglCreateContextAttribsARB(hdc, shared, attributes);
    if (!result)
        qErrnoWarning("%s: wglCreateContextAttribsARB() failed.", __FUNCTION__);
    return result;
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:53,代码来源:qwindowsglcontext.cpp

示例2: context

void GLWidget277::debugContextVersion() {
  QOpenGLContext *ctx = context();
  QSurfaceFormat form = format();
  QSurfaceFormat ctxform = ctx->format();
  QSurfaceFormat::OpenGLContextProfile prof = ctxform.profile();

  const char *profile =
    prof == QSurfaceFormat::CoreProfile ? "Core" :
    prof == QSurfaceFormat::CompatibilityProfile ? "Compatibility" :
    "None";
  int ctxmajor = ctxform.majorVersion();
  int ctxminor = ctxform.minorVersion();
  bool valid = ctx->isValid();
  int formmajor = form.majorVersion();
  int formminor = form.minorVersion();
  const char *vendor = glGS(GL_VENDOR);
  const char *renderer = glGS(GL_RENDERER);
  const char *version = glGS(GL_VERSION);
  const char *s_glsl = glGS(GL_SHADING_LANGUAGE_VERSION);

  printf("Widget version: %d.%d\n", ctxmajor, ctxminor);
  printf("Context valid: %s\n", valid ? "yes" : "NO");
  printf("Format version: %d.%d\n", formmajor, formminor);
  printf("Profile: %s\n", profile);
  printf("  Vendor:   %s\n", vendor);
  printf("  Renderer: %s\n", renderer);
  printf("  Version:  %s\n", version);
  printf("  GLSL:     %s\n", s_glsl);

  QString glsl = s_glsl;
  if (ctxmajor < 3 || glsl.startsWith("1.10") || glsl.startsWith("1.20")) {
    printf("ERROR: "
           "Unable to get an OpenGL 3.x context with GLSL 1.30 or newer. "
           "If your hardware should support it, update your drivers. "
           "If you have switchable graphics, make sure that you are using the discrete GPU.\n");
    QApplication::exit();
  } else if ((ctxmajor == 3 && ctxminor < 2) || glsl.startsWith("1.30") || glsl.startsWith("1.40")) {
    printf("WARNING: "
           "Unable to get an OpenGL 3.2 context with GLSL 1.50. "
           "If your hardware should support it, update your drivers. "
           "If you have switchable graphics, make sure that you are using the discrete GPU. "
           "If you cannot get 3.2 support, it is possible to port this project....");

    // Note: doing this requires at least the following actions:
    // * Change the header and base class in glwidget277.h to 3.0/3.1 instead of 3.2 Core.
    // * Change the shaders to require GLSL 1.30 or 1.40.
  }
}
开发者ID:crydalch,项目名称:Bubble-Streamer,代码行数:48,代码来源:glwidget277.cpp

示例3: 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();
}
开发者ID:JFDesigner,项目名称:Camera,代码行数:35,代码来源:main.cpp

示例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);
  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();
}
开发者ID:NCCA,项目名称:OpenGLCode,代码行数:26,代码来源:main.cpp

示例5: printFormat

void Widget::printFormat(const QSurfaceFormat &format)
{
    m_output->append(tr("OpenGL version: %1.%2").arg(format.majorVersion()).arg(format.minorVersion()));

    for (size_t i = 0; i < sizeof(profiles) / sizeof(Profile); ++i)
        if (profiles[i].profile == format.profile()) {
            m_output->append(tr("Profile: %1").arg(QString::fromLatin1(profiles[i].str)));
            break;
        }

    QString opts;
    for (size_t i = 0; i < sizeof(options) / sizeof(Option); ++i)
        if (format.testOption(options[i].option))
            opts += QString::fromLatin1(options[i].str) + QLatin1Char(' ');
    m_output->append(tr("Options: %1").arg(opts));

    for (size_t i = 0; i < sizeof(renderables) / sizeof(Renderable); ++i)
        if (renderables[i].renderable == format.renderableType()) {
            m_output->append(tr("Renderable type: %1").arg(QString::fromLatin1(renderables[i].str)));
            break;
        }

    m_output->append(tr("Depth buffer size: %1").arg(QString::number(format.depthBufferSize())));
    m_output->append(tr("Stencil buffer size: %1").arg(QString::number(format.stencilBufferSize())));
    m_output->append(tr("Samples: %1").arg(QString::number(format.samples())));
    m_output->append(tr("Red buffer size: %1").arg(QString::number(format.redBufferSize())));
    m_output->append(tr("Green buffer size: %1").arg(QString::number(format.greenBufferSize())));
    m_output->append(tr("Blue buffer size: %1").arg(QString::number(format.blueBufferSize())));
    m_output->append(tr("Alpha buffer size: %1").arg(QString::number(format.alphaBufferSize())));
    m_output->append(tr("Swap interval: %1").arg(QString::number(format.swapInterval())));
}
开发者ID:RSATom,项目名称:Qt,代码行数:31,代码来源:widget.cpp

示例6: fromSurfaceFormat

QT_BEGIN_NAMESPACE

/*!
    Returns an OpenGL format for the window format specified by \a format.
*/
QGLFormat QGLFormat::fromSurfaceFormat(const QSurfaceFormat &format)
{
    QGLFormat retFormat;
    if (format.alphaBufferSize() >= 0)
        retFormat.setAlphaBufferSize(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.depthBufferSize() >= 0)
        retFormat.setDepthBufferSize(format.depthBufferSize());
    if (format.samples() > 1) {
        retFormat.setSampleBuffers(true);
        retFormat.setSamples(format.samples());
    }
    if (format.stencilBufferSize() > 0) {
        retFormat.setStencil(true);
        retFormat.setStencilBufferSize(format.stencilBufferSize());
    }
    retFormat.setDoubleBuffer(format.swapBehavior() != QSurfaceFormat::SingleBuffer);
    retFormat.setStereo(format.stereo());
    retFormat.setVersion(format.majorVersion(), format.minorVersion());
    retFormat.setProfile(static_cast<QGLFormat::OpenGLContextProfile>(format.profile()));
    return retFormat;
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:32,代码来源:qgl_qpa.cpp

示例7: qMakePair

bool QOpenGLFunctions_ES2::isContextCompatible(QOpenGLContext *context)
{
    Q_ASSERT(context);
    QSurfaceFormat f = context->format();
    const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
    if (v < qMakePair(2, 0))
        return false;
    if (f.renderableType() != QSurfaceFormat::OpenGLES)
        return false;

    return true;
}
开发者ID:AlexSoehn,项目名称:qt-base-deb,代码行数:12,代码来源:qopenglfunctions_es2.cpp

示例8: debugFormatVersion

void debugFormatVersion() {
  QSurfaceFormat form = QSurfaceFormat::defaultFormat();
  QSurfaceFormat::OpenGLContextProfile prof = form.profile();

  const char *profile =
    prof == QSurfaceFormat::CoreProfile ? "Core" :
    prof == QSurfaceFormat::CompatibilityProfile ? "Compatibility" :
    "None";

  printf("Requested format:\n");
  printf("  Version: %d.%d\n", form.majorVersion(), form.minorVersion());
  printf("  Profile: %s\n", profile);
}
开发者ID:crydalch,项目名称:Bubble-Streamer,代码行数:13,代码来源:main.cpp

示例9: qMakePair

bool QOpenGLFunctions_4_1_Compatibility::isContextCompatible(QOpenGLContext *context)
{
    Q_ASSERT(context);
    QSurfaceFormat f = context->format();
    const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
    if (v < qMakePair(4, 1))
        return false;

    if (f.profile() == QSurfaceFormat::CoreProfile)
        return false;

    return true;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:13,代码来源:qopenglfunctions_4_1_compatibility.cpp

示例10: initializeContext

int KisOpenGL::initializeContext(QOpenGLContext* s) {
#ifdef HAVE_OPENGL
    KisConfig cfg;
    dbgUI << "OpenGL: Opening new context";

    // Double check we were given the version we requested
    QSurfaceFormat format = s->format();
    glVersion = 100 * format.majorVersion() + format.minorVersion();

    if (!SharedSurface) {
        SharedSurface = new QOffscreenSurface();
        SharedSurface->setFormat(format);
        SharedSurface->create();
    }

    if (!SharedContext) {
        SharedContext = new QOpenGLContext;
        SharedContext->setFormat(format);
        SharedContext->setShareContext(s);
        SharedContext->create();
        SharedContext->makeCurrent(SharedSurface);
    }

    QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();

    QFile log(QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/krita-opengl.txt");
    log.open(QFile::WriteOnly);
    QString vendor((const char*)f->glGetString(GL_VENDOR));
    log.write(vendor.toLatin1());
    log.write(", ");
    QString renderer((const char*)f->glGetString(GL_RENDERER));
    log.write(renderer.toLatin1());
    log.write(", ");
    QString version((const char*)f->glGetString(GL_VERSION));
    log.write(version.toLatin1());

    // Check if we have a bugged driver that needs fence workaround
    bool isOnX11 = false;
#ifdef HAVE_X11
    isOnX11 = true;
#endif

    if ((isOnX11 && renderer.startsWith("AMD")) || cfg.forceOpenGLFenceWorkaround()) {
        NeedsFenceWorkaround = true;
    }
#else
    Q_UNUSED(s);
    NeedsFenceWorkaround = false;
#endif
    return glVersion;
}
开发者ID:woylaski,项目名称:kexi,代码行数:51,代码来源:kis_opengl.cpp

示例11: testProperties

void tst_QQuickOpenGLInfo::testProperties()
{
    QQuickView view;
    view.setSource(testFileUrl("basic.qml"));

    view.show();
    QVERIFY(QTest::qWaitForWindowExposed(&view));

    QSignalSpy spy(&view, SIGNAL(sceneGraphInitialized()));
    spy.wait();

    QVERIFY(view.openglContext());
    QSurfaceFormat format = view.openglContext()->format();

    QObject* obj = view.rootObject();
    QVERIFY(obj);
    QCOMPARE(obj->property("majorVersion").toInt(), format.majorVersion());
    QCOMPARE(obj->property("minorVersion").toInt(), format.minorVersion());
    QCOMPARE(obj->property("profile").toInt(), static_cast<int>(format.profile()));
    QCOMPARE(obj->property("renderableType").toInt(), static_cast<int>(format.renderableType()));
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:21,代码来源:tst_qquickopenglinfo.cpp

示例12: displayString


//.........这里部分代码省略.........
  if (value.userType() == qMetaTypeId<QPainterPath>()) {
    const QPainterPath path = value.value<QPainterPath>();
    if (path.isEmpty()) {
      return QObject::tr("<empty>");
    }
    return QObject::tr("<%1 elements>").arg(path.elementCount());
  }

  if (value.userType() == qMetaTypeId<QMargins>()) {
    const QMargins margins = value.value<QMargins>();
    return QObject::tr("left: %1, top: %2, right: %3, bottom: %4")
       .arg(margins.left()).arg(margins.top())
       .arg(margins.right()).arg(margins.bottom());
  }

  if (value.canConvert<QObject*>()) {
    return Util::displayString(value.value<QObject*>());
  }

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
  if (value.userType() == qMetaTypeId<QSet<QByteArray> >()) {
    const QSet<QByteArray> set = value.value<QSet<QByteArray> >();
    QStringList l;
    foreach (const QByteArray &b, set)
      l.push_back(QString::fromUtf8(b));
    return l.join(", ");
  }

  if (value.userType() == qMetaTypeId<QSurfaceFormat>()) {
    const QSurfaceFormat format = value.value<QSurfaceFormat>();
    QString s;
    switch (format.renderableType()) {
      case QSurfaceFormat::DefaultRenderableType: s += "Default"; break;
      case QSurfaceFormat::OpenGL: s += "OpenGL"; break;
      case QSurfaceFormat::OpenGLES: s += "OpenGL ES"; break;
      case QSurfaceFormat::OpenVG: s += "OpenVG"; break;
    }

    s += " (" + QString::number(format.majorVersion()) + "." + QString::number(format.minorVersion());
    switch (format.profile()) {
      case QSurfaceFormat::CoreProfile: s += " core"; break;
      case QSurfaceFormat::CompatibilityProfile: s += " compat"; break;
      case QSurfaceFormat::NoProfile: break;
    }
    s += ")";

    s += " RGBA: " + QString::number(format.redBufferSize()) + "/" + QString::number(format.greenBufferSize())
      + "/" + QString::number(format.blueBufferSize()) + "/" + QString::number(format.alphaBufferSize());

    s += " Depth: " + QString::number(format.depthBufferSize());
    s += " Stencil: " + QString::number(format.stencilBufferSize());

    s += " Buffer: ";
    switch (format.swapBehavior()) {
      case QSurfaceFormat::DefaultSwapBehavior: s += "default"; break;
      case QSurfaceFormat::SingleBuffer: s += "single"; break;
      case QSurfaceFormat::DoubleBuffer: s += "double"; break;
      case QSurfaceFormat::TripleBuffer: s += "triple"; break;
      default: s += "unknown";
    }

    return s;
  }

  if (value.userType() == qMetaTypeId<QSurface::SurfaceClass>()) {
    const QSurface::SurfaceClass sc = value.value<QSurface::SurfaceClass>();
    switch (sc) {
      case QSurface::Window: return QObject::tr("Window");
#if QT_VERSION > QT_VERSION_CHECK(5, 1, 0)
      case QSurface::Offscreen: return QObject::tr("Offscreen");
#endif
      default: return QObject::tr("Unknown Surface Class");
    }
  }

  if (value.userType() == qMetaTypeId<QSurface::SurfaceType>()) {
    const QSurface::SurfaceType type = value.value<QSurface::SurfaceType>();
    switch (type) {
      case QSurface::RasterSurface: return QObject::tr("Raster");
      case QSurface::OpenGLSurface: return QObject::tr("OpenGL");
      default: return QObject::tr("Unknown Surface Type");
    }
  }

#endif

  // enums
  const QString enumStr = Util::enumToString(value);
  if (!enumStr.isEmpty()) {
    return enumStr;
  }

  // custom converters
  const QHash<int, Converter<QString>*>::const_iterator it = s_variantHandlerRepository()->stringConverters.constFind(value.userType());
  if (it != s_variantHandlerRepository()->stringConverters.constEnd()) {
    return (*it.value())(value);
  }

  return value.toString();
}
开发者ID:bschuste,项目名称:GammaRay,代码行数:101,代码来源:varianthandler.cpp

示例13: main

int main(int argc, char **argv)

//CLOCK/TIMER
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

{
//Test if clock is working correctly - pause for x seconds

{

    for (int i = 0; i<10;i++)
    {
        std::cout<<i<<"\n";
        std::this_thread::sleep_for(std::chrono::seconds(1));
    }

}

//DISTANCE
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

{
  Distance p1,p2,p3;
  p1.setCoords(7,8,3); //input coordinates
  p2.setCoords(1,1,1);

  p3=p1.minus(p2);

  std::cout<<"\n Particle 1 Coordinates are: "; p1.disp();
  std::cout<<"\n Particle 2 Coordinates are: "; p2.disp();
  std::cout<<"\n Distance between particle coordinates: "; p3.disp();

}

//CIRCLE
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

//  Circle circleOBJ;

//  float rad;

//  std::cout<<"Enter a radius: "<<std::endl;
//  std::cin>>rad;

//  circleOBJ.setradius(rad);
//  circleOBJ.print();

////return 0;



//NGLscene
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

{
  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
  window.resize(1024, 720);
  // and finally show
  window.show();

  return app.exec();
}
}
开发者ID:RuthHutton,项目名称:ComputingProject2016,代码行数:89,代码来源:main.cpp

示例14: init

void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLContext *share)
{
    m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig);
    // m_format now has the renderableType() resolved (it cannot be Default anymore)
    // but does not yet contain version, profile, options.
    m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : 0;

    QVector<EGLint> contextAttrs;
    contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
    contextAttrs.append(format.majorVersion());
    const bool hasKHRCreateContext = q_hasEglExtension(m_eglDisplay, "EGL_KHR_create_context");
    if (hasKHRCreateContext) {
        contextAttrs.append(EGL_CONTEXT_MINOR_VERSION_KHR);
        contextAttrs.append(format.minorVersion());
        int flags = 0;
        // The debug bit is supported both for OpenGL and OpenGL ES.
        if (format.testOption(QSurfaceFormat::DebugContext))
            flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
        // The fwdcompat bit is only for OpenGL 3.0+.
        if (m_format.renderableType() == QSurfaceFormat::OpenGL
            && format.majorVersion() >= 3
            && !format.testOption(QSurfaceFormat::DeprecatedFunctions))
            flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
        if (flags) {
            contextAttrs.append(EGL_CONTEXT_FLAGS_KHR);
            contextAttrs.append(flags);
        }
        // Profiles are OpenGL only and mandatory in 3.2+. The value is silently ignored for < 3.2.
        if (m_format.renderableType() == QSurfaceFormat::OpenGL) {
            contextAttrs.append(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
            contextAttrs.append(format.profile() == QSurfaceFormat::CoreProfile
                                ? EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR
                                : EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR);
        }
    }
    contextAttrs.append(EGL_NONE);

    switch (m_format.renderableType()) {
    case QSurfaceFormat::OpenVG:
        m_api = EGL_OPENVG_API;
        break;
#ifdef EGL_VERSION_1_4
    case QSurfaceFormat::OpenGL:
        m_api = EGL_OPENGL_API;
        break;
#endif // EGL_VERSION_1_4
    default:
        m_api = EGL_OPENGL_ES_API;
        break;
    }

    eglBindAPI(m_api);
    m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, m_shareContext, contextAttrs.constData());
    if (m_eglContext == EGL_NO_CONTEXT && m_shareContext != EGL_NO_CONTEXT) {
        m_shareContext = 0;
        m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, 0, contextAttrs.constData());
    }

    if (m_eglContext == EGL_NO_CONTEXT) {
        qWarning("QEGLPlatformContext: Failed to create context: %x", eglGetError());
        return;
    }

    static const bool printConfig = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DEBUG");
    if (printConfig) {
        qDebug() << "Created context for format" << format << "with config:";
        q_printEglConfig(m_eglDisplay, m_eglConfig);
    }

    // Cannot just call updateFormatFromGL() since it relies on virtuals. Defer it to initialize().
}
开发者ID:Sagaragrawal,项目名称:2gisqt5android,代码行数:71,代码来源:qeglplatformcontext.cpp

示例15: doRendering

void HsQMLCanvasBackEnd::doRendering()
{
    if (!mGL) {
        mGL = mWindow->openglContext();
        QObject::connect(
            mGL, SIGNAL(aboutToBeDestroyed()), this, SLOT(doCleanup()));
        HsQMLGLCanvasType ctype;
        QSurfaceFormat format = mGL->format();
        switch (format.renderableType()) {
            case QSurfaceFormat::OpenGL: ctype = HSQML_GL_DESKTOP; break;
            case QSurfaceFormat::OpenGLES: ctype = HSQML_GL_ES; break;
            default: setStatus(HsQMLCanvas::BadConfig); return;
        }
        mGLViewportFn = reinterpret_cast<GLViewportFn>(
            mGL->getProcAddress("glViewport"));
        mGLClearColorFn = reinterpret_cast<GLClearColorFn>(
            mGL->getProcAddress("glClearColor"));
        mGLClearFn = reinterpret_cast<GLClearFn>(
            mGL->getProcAddress("glClear"));
        if (!mGLViewportFn || !mGLClearColorFn || !mGLClearFn) {
            setStatus(HsQMLCanvas::BadProcs);
            return;
        }
        mGLCallbacks->mSetupCb(
            ctype, format.majorVersion(), format.minorVersion());
    }

    // Reset OpenGL state before rendering
#if QT_VERSION >= 0x050200
    mWindow->resetOpenGLState();
#else
#warning Resetting OpenGL state requires Qt 5.2 or later
#endif

    // Clear window if painting below the scenegraph
    if (mWinInfo.needsBelowClear()) {
        QColor bg = mWindow->color();
        mGLClearColorFn(bg.redF(), bg.greenF(), bg.blueF(), bg.alphaF());
        mGLClearFn(GL_COLOR_BUFFER_BIT);
    }

    // Setup prior to paint callback
    QMatrix4x4 matrix;
    bool inlineMode = HsQMLCanvas::Inline == mDisplayMode;
    if (inlineMode) {
        if (!mFBO->bind()) {
            setStatus(HsQMLCanvas::BadBind);
            return;
        }
        mGLViewportFn(0, 0, qCeil(mCanvasWidth), qCeil(mCanvasHeight));

        // Clear FBO to transparent
        mGLClearColorFn(0, 0, 0, 0);
        mGLClearFn(GL_COLOR_BUFFER_BIT);
    }
    else {
        // Calculate matrix for non-inline display modes
        QMatrix4x4 smatrix;
        QSGNode* node = mTransformNode;
        while (node) {
            if (QSGNode::TransformNodeType == node->type()) {
                QSGTransformNode* tnode = static_cast<QSGTransformNode*>(node);
                smatrix = tnode->matrix() * smatrix;
            }
            node = node->parent();
        }
        matrix.translate(-1, 1);
        matrix.scale(2.0f/mWindow->width(), -2.0f/mWindow->height());
        matrix *= smatrix;
        matrix.scale(mItemWidth/2.0f, mItemHeight/2.0f);
        matrix.translate(1, 1);

        mGLViewportFn(0, 0, mWindow->width(), mWindow->height());
    }

    setStatus(HsQMLCanvas::Okay);
    mGLCallbacks->mPaintCb(matrix.data(), mItemWidth, mItemHeight);

    if (inlineMode) {
        mFBO->release();
    }
}
开发者ID:johntyree,项目名称:HsQML,代码行数:82,代码来源:Canvas.cpp


注:本文中的QSurfaceFormat::minorVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。