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


C++ ShaderProgram::getLog方法代码示例

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


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

示例1: createDefaultShader

ShaderProgram* SpriteCache::createDefaultShader () {
    if (!Gdx::graphics->isGL20Available()) return NULL;
    std::string vertexShader = "attribute vec4 " + ShaderProgram::POSITION_ATTRIBUTE + ";\n" //
     "attribute vec4 " + ShaderProgram::COLOR_ATTRIBUTE + ";\n" //
     "attribute vec2 " + ShaderProgram::TEXCOORD_ATTRIBUTE + "0;\n" //
     "uniform mat4 u_projectionViewMatrix;\n" //
     "varying vec4 v_color;\n" //
     "varying vec2 v_texCoords;\n" //
     "\n" //
     "void main()\n" //
     "{\n" //
     "   v_color = " + ShaderProgram::COLOR_ATTRIBUTE + ";\n" //
     "   v_texCoords = " + ShaderProgram::TEXCOORD_ATTRIBUTE + "0;\n" //
     "   gl_Position =  u_projectionViewMatrix * " + ShaderProgram::POSITION_ATTRIBUTE + ";\n" //
     "}\n";
    std::string fragmentShader = "#ifdef GL_ES\n" //
     "precision mediump float;\n" //
     "#endif\n" //
     "varying vec4 v_color;\n" //
     "varying vec2 v_texCoords;\n" //
     "uniform sampler2D u_texture;\n" //
     "void main()\n"//
     "{\n" //
     "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n" //
     "}";

    ShaderProgram* shader = new ShaderProgram(vertexShader, fragmentShader);
    if (shader->isCompiled() == false)
        throw std::runtime_error("Error compiling shader: " + shader->getLog());
    return shader;
}
开发者ID:ozires,项目名称:libgdx-cpp,代码行数:31,代码来源:SpriteCache.cpp

示例2: buildCurrentProject

void GLShaderDev::buildCurrentProject()
{
    ShaderProgram*  prog = new ShaderProgram;
    bool            success = true;
    int             i = 1;
    OutputParser    parser(_glInfo.getVendor());
    const ShaderProject::Stages&  stages = _projectManager.getCurrentProject()->getStages();

    _editor->saveAll();
    _output->getModel()->clear();
    _buildOutputDock->setVisible(true);

    for (ShaderProject::Stages::const_iterator it = stages.begin(); it != stages.end(); ++it)
    {
        QFile       file(it->second);
        QFileInfo       fileInfo(file);
        ShaderObject*   obj = new ShaderObject;
        QString     str = QString(tr("[%1/%2] Compiling %3...")).arg(i).arg(stages.size()).arg(fileInfo.fileName());

        _output->getModel()->addItem(OutputItem(str, OutputItem::InformationItem));
        if (!file.open(QIODevice::ReadOnly))
            throw (GlsdException(std::string("Could not open shader file") + it->second.toStdString())); // TODO proper exception handling
            if (!obj->compile(QString(file.readAll()).toStdString(), static_cast<ShaderObject::ShaderType>(it->first)))
            {
                _output->getModel()->addItems(parser.parse(obj->getErrorLog(), fileInfo.absoluteFilePath().toStdString()));
                success = false;
            }
            prog->attach(*obj);
        ++i;
    }

    _output->getModel()->addItem(OutputItem(tr("Linking shader..."), OutputItem::InformationItem));
    if (!prog->link())
    {
        _output->getModel()->addItem(OutputItem(prog->getLog().c_str(), OutputItem::ErrorItem));
        success = false;
    }

    if (!success)
    {
        _output->getModel()->addItem(OutputItem(tr("*** Compilation failed ***"), OutputItem::StandardItem));
        return;
    }
    _output->getModel()->addItem(OutputItem(tr("*** Compilation successful ***"), OutputItem::StandardItem));
    // FIXME Set shader properly, with attributes correctly bound
    _glwidget->setShader(prog);
    prog->printDebug();
}
开发者ID:Ryp,项目名称:GLShaderDev,代码行数:48,代码来源:GLShaderDev.cpp


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