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


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

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


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

示例1: checkVersion

static bool checkVersion(QOpenGLContext &context, QSurfaceFormat &format)
{
  QSurfaceFormat currSurface = context.format();
  QPair<int,int> currVersion = currSurface.version();
  QPair<int,int> reqVersion = format.version();
  if (currVersion.first > reqVersion.first)
    return true;
  return (currVersion.first == reqVersion.first && currVersion.second >= reqVersion.second);
}
开发者ID:kyunghoWon,项目名称:QtOpenGL,代码行数:9,代码来源:main.cpp

示例2: QOpenGLWidget

Window::Window()
  : QOpenGLWidget()
{
  QSurfaceFormat format;
  format.setSamples(8);
  format.setStencilBufferSize(8);
  setFormat(format);
  printf("Version Major:%d minor:%d \n",format.version().first, format.version().second);
  datachanged = colorchanged = true;
}
开发者ID:ansjcy,项目名称:network-summer,代码行数:10,代码来源:mainwindow.cpp

示例3: 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);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:17,代码来源:tst_qsurfaceformat.cpp

示例4: create

bool QOpenGLTextureBlitter::create()
{
    QOpenGLContext *currentContext = QOpenGLContext::currentContext();
    if (!currentContext)
        return false;

    Q_D(QOpenGLTextureBlitter);

    d->vao->create();
    d->vao->bind();

    if (d->program)
        return true;

    d->program.reset(new QOpenGLShaderProgram());

    QSurfaceFormat format = currentContext->format();

    if (format.profile() == QSurfaceFormat::CoreProfile && format.version() >= qMakePair(3,2)) {
        d->program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertex_shader150);
        d->program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragment_shader150);
    } else {
        d->program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertex_shader);
        d->program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragment_shader);
    }
    d->program->link();
    if (!d->program->isLinked()) {
        qWarning() << Q_FUNC_INFO << "Could not link shader program:\n" << d->program->log();
        return false;
    }

    d->program->bind();

    d->vertexBuffer.create();
    d->vertexBuffer.bind();
    d->vertexBuffer.allocate(vertex_buffer_data, sizeof(vertex_buffer_data));
    d->vertexBuffer.release();

    d->textureBuffer.create();
    d->textureBuffer.bind();
    d->textureBuffer.allocate(texture_buffer_data, sizeof(texture_buffer_data));
    d->textureBuffer.release();

    d->vertexCoordAttribPos = d->program->attributeLocation("vertexCoord");
    d->vertexTransformUniformPos = d->program->uniformLocation("vertexTransform");
    d->textureCoordAttribPos = d->program->attributeLocation("textureCoord");
    d->textureTransformUniformPos = d->program->uniformLocation("textureTransform");
    d->swizzleUniformPos = d->program->uniformLocation("swizzle");

    d->program->setUniformValue(d->swizzleUniformPos,false);

    d->vao->release();

    return true;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:55,代码来源:qopengltextureblitter.cpp

示例5: f

QtOpenGLWindowBase::QtOpenGLWindowBase(const QSurfaceFormat & format)
: m_context(new QOpenGLContext)
, m_initialized(false)
, m_updatePending(false)
{
    QSurfaceFormat f(format);
    f.setRenderableType(QSurfaceFormat::OpenGL);

    setSurfaceType(OpenGLSurface);
    create();

    if (f.version().first < 3)
    {
        m_context->setFormat(f);
        if (!m_context->create()) {
            qDebug() << "Could not create intermediate OpenGL context.";
            QApplication::quit();
        } else {
            QSurfaceFormat intermediateFormat = m_context->format();
            qDebug().nospace() << "Created intermediate OpenGL context " << intermediateFormat.version().first << "." << intermediateFormat.version().second;

            if ((intermediateFormat.version().first == 3 && intermediateFormat.version().second == 0) || intermediateFormat.version().first < 3)
            {
                f.setMajorVersion(3);
                f.setMinorVersion(2);
                f.setProfile(QSurfaceFormat::CoreProfile);
            }
        }
    }

    m_context->setFormat(f);
    if (!m_context->create()) {
        qDebug() << "Could not create OpenGL context.";
        QApplication::quit();
    } else {
        qDebug().nospace() << "Created OpenGL context " << m_context->format().version().first << "." << m_context->format().version().second;
    }
}
开发者ID:SebSchmech,项目名称:gloperate,代码行数:38,代码来源:QtOpenGLWindowBase.cpp

示例6: init

void NcRenderingLayer::init(NcMapView *view)
{
    // shaders
	QSurfaceFormat glf = QSurfaceFormat::defaultFormat();
	qDebug()<<"Glversion ="<<glf.version();
    this->shader = new QOpenGLShaderProgram();
    this->shader->addShaderFromSourceFile(QOpenGLShader::Vertex, ":shaders/simple.vert");
    this->shader->addShaderFromSourceFile(QOpenGLShader::Fragment, ":shaders/color.frag");
    this->shader->link();

	this->rect_shader =  new QOpenGLShaderProgram();
    this->rect_shader->addShaderFromSourceFile(QOpenGLShader::Vertex, ":shaders/simple.vert");
    this->rect_shader->addShaderFromSourceFile(QOpenGLShader::Fragment, ":shaders/rect_color.frag");
    this->rect_shader->link();
    glGenVertexArrays(1, &this->vao);
    glGenBuffers(1, &this->vbo);
    glGenBuffers(1, &this->colorbuffer);

//    QPointF origin = QPointF(0,0);//view->getOrigin();
//    QPointF wTopRight  = view->cam()->geo2world(view->getGeoBounds().bottomLeft()) - origin;
//    QPointF wBottomRight = view->cam()->geo2world(view->getGeoBounds().bottomRight()) - origin;
//    QPointF wTopLeft     = view->cam()->geo2world(view->getGeoBounds().topLeft()) - origin;
//    QPointF wBottomLeft  = view->cam()->geo2world(view->getGeoBounds().topRight()) - origin;
//    QPointF wTopLeft  = QVector3DD(253522375.1, 432502876, -9.968698493).toPointF() - origin;
//    QPointF wBottomLeft = QVector3DD(253522375.1, 432234063.2, -9.968698493).toPointF() - origin;
//    QPointF wTopRight     = QVector3DD(253880792.2, 432502876, -9.968698493).toPointF() - origin;
//    QPointF wBottomRight  = QVector3DD(253880792.2, 432234063.2, -9.968698493).toPointF() - origin;

//    qDebug() << wBottomLeft << wBottomRight << wTopLeft << wTopRight;
    float z = 0;
    float points[] = {
//        wBottomLeft.x(),-wBottomLeft.y(), z,
//        0, 0, z,
//        wBottomRight.x(),-wBottomRight.y(),  z,
//        wTopRight.x(), -wTopRight.y(),  z,
//        wBottomLeft.x(),-wBottomLeft.y(), z,
//        wTopRight.x(), -wTopRight.y(),  z,
//        wTopLeft.x(), -wTopLeft.y(), z
//        0.0f,1.0f, z,
//        1.0f,1.0f, z,
//        1.0f,0.0f, z,
//        0.0f,1.0f, z,
//        1.0f,0.0f, z,
//        0.0f,0.0f, z
        0.0, 0.0, 0.0,
        1.0, 0.0, 0.0,
        0.0, 1.0, 0.0,
        1.0, 0.0, 0.0,
        1.0, 1.0, 0.0,
        0.0, 1.0, 0.0
    };

    float colors[] = {
        1,0,0,
        0,0,1,
        1,0,0,
        1,0,0,
        1,0,1,
        1,0,0
    };

    glBindBuffer(GL_ARRAY_BUFFER, this->vbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    glBindBuffer(GL_ARRAY_BUFFER, this->colorbuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    // texture
    createTexImage2D(view->getWidth(), view->getHeight(), GL_R32F, GL_RED, GL_FLOAT, &this->tex, (void*)view->getData().data());

//	this->rectangle(0.2,0.2,0.5,0.5);
}
开发者ID:MeepoLi,项目名称:inforProject,代码行数:74,代码来源:NcRenderingLayer.cpp


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