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


C++ QOpenGLShader::log方法代码示例

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


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

示例1: file

Shader::Shader(QString vshaderName, QString fshaderName, QObject *parent)
    :QOpenGLShaderProgram(parent)
{
    QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, parent);
    {
        QFile file(":/res/Shaders/"+vshaderName+".vert");
        if (file.open(QIODevice::ReadOnly)) {
            QString vsrc = file.readAll();
            if (!vshader->compileSourceCode(vsrc)){
                printf("%s", vshader->log().data());
                exit(1);
            }
        }
    }

    QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, parent);
    {
        QFile file(":/res/Shaders/"+fshaderName+".frag");
        if (file.open(QIODevice::ReadOnly)) {
            QString fsrc = file.readAll();
            if (!fshader->compileSourceCode(fsrc)){
                printf("%s", fshader->log().data());
                exit(1);
            }
        }
    }
    this->addShader(vshader);
    this->addShader(fshader);
    this->bindAttributeLocation("vertex", PROGRAM_VERTEX_ATTRIBUTE);
    this->bindAttributeLocation("texCoord", PROGRAM_TEXCOORD_ATTRIBUTE);
    this->bindAttributeLocation("lightPosition", PROGRAM_LIGHT_POSITION_ATTRIBUTE);
    this->bindAttributeLocation("lightColour", PROGRAM_LIGHT_COLOUR_ATTRIBUTE);
    this->bindAttributeLocation("useTexture", PROGRAM_USE_TEXTURE);
    if (!this->link())
    {
        printf("%s", this->log().data());
        exit(1);
    }
    this->bind();
    this->setUniformValue("texture", 0);
}
开发者ID:Victer3965,项目名称:OGL2,代码行数:41,代码来源:shader.cpp

示例2: initializeGL

void GLWidget::initializeGL()
{
    initializeOpenGLFunctions();
    glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
    makeCurrent();
    qglClearColor(QColor::fromCmykF(0.79, 0.79, 0.79, 0.0).dark());


    glEnable(GL_DEPTH_TEST);
    glEnable(GL_MULTISAMPLE);
    glEnable(GL_DEPTH_TEST);


    qDebug() << "Loading quad (vertex shader)";
    QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
    vshader->compileSourceFile(":/resources/plane.vert");
    if (!vshader->log().isEmpty()) qDebug() << vshader->log();
    else qDebug() << "done";

    qDebug() << "Loading quad (fragment shader)";
    QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);
    fshader->compileSourceFile(":/resources/plane.frag");
    if (!fshader->log().isEmpty()) qDebug() << fshader->log();
    else qDebug() << "done";

    qDebug() << "Loading quad (tessellation control shader)";
    QOpenGLShader *tcshader = new QOpenGLShader(QOpenGLShader::TessellationControl, this);
    tcshader->compileSourceFile(":/resources/plane.tcs.vert");
    if (!tcshader->log().isEmpty()) qDebug() << tcshader->log();
    else qDebug() << "done";

    qDebug() << "Loading quad (tessellation evaluation shader)";
    QOpenGLShader *teshader = new QOpenGLShader(QOpenGLShader::TessellationEvaluation, this);
    teshader->compileSourceFile(":/resources/plane.tes.vert");
    if (!teshader->log().isEmpty()) qDebug() << teshader->log();
    else qDebug() << "done";

    qDebug() << "Loading quad (geometry shader)";
    QOpenGLShader *gshader = new QOpenGLShader(QOpenGLShader::Geometry, this);
    QFile gFile(":/resources/plane.geom");
    gFile.open(QFile::ReadOnly);
    qDebug() << gFile.isOpen() << " File";

    QTextStream in(&gFile);
    QString preambule = "#version 400 core\n"
                        "layout(triangle_strip, max_vertices = 3) out;\n" ;
    QString shaderCode = in.readAll();
    gshader->compileSourceCode(preambule+shaderCode);
    //gshader->compileSourceFile(in.readAll());
    if (!gshader->log().isEmpty()) qDebug() << gshader->log();
    else qDebug() << "done";

    program = new QOpenGLShaderProgram(this);
    program->addShader(vshader);
    program->addShader(fshader);
    program->addShader(tcshader);
    program->addShader(teshader);
    program->addShader(gshader);
    program->bindAttributeLocation("FragColor",0);
    program->bindAttributeLocation("FragNormal",1);
    program->bindAttributeLocation("FragGlowColor",2);
    program->bindAttributeLocation("FragPosition",3);
    GLCHK(program->link());

    GLCHK(program->bind());
    program->setUniformValue("texDiffuse"  , 0);
    program->setUniformValue("texNormal"   , 1);
    program->setUniformValue("texSpecular" , 2);
    program->setUniformValue("texHeight"   , 3);
    program->setUniformValue("texSSAO"     , 4);
    program->setUniformValue("texRoughness", 5);
    program->setUniformValue("texMetallic",  6);
    program->setUniformValue("texMaterial",  7);

    program->setUniformValue("texDiffuseEnvMap", 8);
    program->setUniformValue("texEnvMap"       , 9);

    // lines shader
    qDebug() << "Compiling lines program...";
    preambule = QString("#version 400 core\n")+
                        "layout(line_strip, max_vertices = 3) out;\n" ;
    gshader->compileSourceCode(preambule+shaderCode);

    line_program = new QOpenGLShaderProgram(this);
    line_program->addShader(vshader);
    line_program->addShader(fshader);
    line_program->addShader(tcshader);
    line_program->addShader(teshader);
    line_program->addShader(gshader);
    line_program->bindAttributeLocation("FragColor",0);
    line_program->bindAttributeLocation("FragNormal",1);
    line_program->bindAttributeLocation("FragGlowColor",2);
    line_program->bindAttributeLocation("FragPosition",3);
    GLCHK(line_program->link());

    GLCHK(line_program->bind());
    line_program->setUniformValue("texDiffuse"  , 0);
    line_program->setUniformValue("texNormal"   , 1);
    line_program->setUniformValue("texSpecular" , 2);
    line_program->setUniformValue("texHeight"   , 3);
//.........这里部分代码省略.........
开发者ID:Chrizzldi,项目名称:AwesomeBump,代码行数:101,代码来源:glwidget.cpp


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