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


C++ QOpenGLShaderProgram::addShaderFromSourceCode方法代码示例

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


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

示例1: load

	void load() {
		shader.addShaderFromSourceCode(QOpenGLShader::Vertex,
		                               shaderWithHeader(":/shaders/mvp.vert"));
		shader.addShaderFromSourceCode(QOpenGLShader::Fragment,
		                               shaderWithHeader(":/shaders/flat.frag"));
		shader.link();
		cube.load(shader);
	}
开发者ID:jdisset,项目名称:seacells,代码行数:8,代码来源:drawextensions.hpp

示例2: exposeEvent

    void exposeEvent(QExposeEvent *)
    {
        if (!isExposed())
            return;

        if (!gl) {
            gl = new QOpenGLContext();
            gl->setFormat(requestedFormat());
            gl->create();
        }

        gl->makeCurrent(this);

        QOpenGLShaderProgram prog;
        prog.addShaderFromSourceCode(QOpenGLShader::Vertex,
                                     "attribute highp vec4 a_Pos;"
                                     "attribute lowp vec4 a_Color;"
                                     "varying lowp vec4 v_Color;"
                                     "void main() {"
                                     "    gl_Position = a_Pos;"
                                     "    v_Color = a_Color;"
                                     "}");
        prog.addShaderFromSourceCode(QOpenGLShader::Fragment,
                                     "varying lowp vec4 v_Color;"
                                     "void main() {"
                                     "    gl_FragColor = v_Color;"
                                     "}");
        prog.bind();

        glClearColor(0, 0, 0, 1);
        glClear(GL_COLOR_BUFFER_BIT);
        glViewport(0, 0, width(), height());

        prog.enableAttributeArray("a_Pos");
        prog.enableAttributeArray("a_Color");

        float coords[] = { -0.7f,  0.7f,
                           0.8f,  0.8f,
                           -0.8f, -0.8f,
                           0.7f, -0.7f
                         };
        float colors[] = { 1, 0, 0, 1,
                           0, 1, 0, 1,
                           0, 0, 1, 1,
                           0, 0, 0, 0
                         };

        prog.setAttributeArray("a_Pos", GL_FLOAT, coords, 2, 0);
        prog.setAttributeArray("a_Color", GL_FLOAT, colors, 4, 0);

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

        prog.disableAttributeArray("a_Pos");
        prog.disableAttributeArray("a_Color");

        gl->swapBuffers(this);
    }
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:57,代码来源:windowtransparency.cpp

示例3: initialize

//! [4]
void TriangleWindow::initialize()
{
    m_program = new QOpenGLShaderProgram(this);
    m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
    m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
    m_program->link();
    m_posAttr = m_program->attributeLocation("posAttr");
    m_colAttr = m_program->attributeLocation("colAttr");
    m_matrixUniform = m_program->uniformLocation("matrix");
}
开发者ID:RSATom,项目名称:Qt,代码行数:11,代码来源:main.cpp

示例4: initShader

    void initShader(QOpenGLShaderProgram& _s, const char *_filename) {
      QString _vertSrc =
        ShaderCompiler::compile(":/shaders/" + QString(_filename) + ".vert");
      QString _fragmentSrc =
        ShaderCompiler::compile(":/shaders/" + QString(_filename) + ".frag");

      _s.addShaderFromSourceCode(QOpenGLShader::Vertex,
                                 _vertSrc);
      _s.addShaderFromSourceCode(QOpenGLShader::Fragment,
                                 _fragmentSrc);
      _s.link();
    }
开发者ID:cr8tr,项目名称:omnidome,代码行数:12,代码来源:Shader.cpp

示例5: loadShader

void DVWindow::loadShader(QOpenGLShaderProgram& shader, const char* vshader, const char* fshader) {
    /* Load the shaders from the qrc. */
    shader.addShaderFromSourceFile(QOpenGLShader::Vertex, vshader);

    QFile res(fshader);
    res.open(QIODevice::ReadOnly | QIODevice::Text);
    QString fshaderSrc = res.readAll();

    if (!context()->isOpenGLES())
        fshaderSrc.prepend("#version 130\n");

    shader.addShaderFromSourceCode(QOpenGLShader::Fragment, fshaderSrc);

    /* Bind the attribute handles. */
    shader.bindAttributeLocation("vertex", vertex);
    shader.bindAttributeLocation("uv", uv);

    shader.link();

    /* Bind so we set the texture sampler uniform values. */
    shader.bind();

    /* Left image is TEXTURE0. */
    shader.setUniformValue("textureL", 0);
    /* Right image is TEXTURE1. */
    shader.setUniformValue("textureR", 1);
}
开发者ID:chipgw,项目名称:depthview2,代码行数:27,代码来源:dvwindow.cpp


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