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


C++ ProgramObject::uniformLocation方法代码示例

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


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

示例1: initSkinProgram

void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locations) {
    program.bind();
    locations.clusterMatrices = program.uniformLocation("clusterMatrices");
    locations.clusterIndices = program.attributeLocation("clusterIndices");
    locations.clusterWeights = program.attributeLocation("clusterWeights");
    locations.tangent = program.attributeLocation("tangent");
    program.setUniformValue("diffuseMap", 0);
    program.setUniformValue("normalMap", 1);
    program.release();
}
开发者ID:BogusCurry,项目名称:hifi,代码行数:10,代码来源:Model.cpp

示例2: loadLightProgram

void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limited, ProgramObject& program, LightLocations& locations) {
    program.addShaderFromSourceCode(QGLShader::Vertex, (limited ? deferred_light_limited_vert : deferred_light_vert));
    program.addShaderFromSourceCode(QGLShader::Fragment, fragSource);
    program.link();
    
    program.bind();
    program.setUniformValue("diffuseMap", 0);
    program.setUniformValue("normalMap", 1);
    program.setUniformValue("specularMap", 2);
    program.setUniformValue("depthMap", 3);
    program.setUniformValue("shadowMap", 4);
    program.setUniformValue("skyboxMap", 5);
    locations.shadowDistances = program.uniformLocation("shadowDistances");
    locations.shadowScale = program.uniformLocation("shadowScale");
    locations.nearLocation = program.uniformLocation("near");
    locations.depthScale = program.uniformLocation("depthScale");
    locations.depthTexCoordOffset = program.uniformLocation("depthTexCoordOffset");
    locations.depthTexCoordScale = program.uniformLocation("depthTexCoordScale");
    locations.radius = program.uniformLocation("radius");
    locations.ambientSphere = program.uniformLocation("ambientSphere.L00");
    locations.invViewMat = program.uniformLocation("invViewMat");

    GLint loc = -1;

#if (GPU_FEATURE_PROFILE == GPU_CORE)
    const GLint LIGHT_GPU_SLOT = 3;
    loc = glGetUniformBlockIndex(program.programId(), "lightBuffer");
    if (loc >= 0) {
        glUniformBlockBinding(program.programId(), loc, LIGHT_GPU_SLOT);
        locations.lightBufferUnit = LIGHT_GPU_SLOT;
    } else {
        locations.lightBufferUnit = -1;
    }
#else
    loc = program.uniformLocation("lightBuffer");
    if (loc >= 0) {
        locations.lightBufferUnit = loc;
    } else {
        locations.lightBufferUnit = -1;
    }
#endif

#if (GPU_FEATURE_PROFILE == GPU_CORE)
    const GLint ATMOSPHERE_GPU_SLOT = 4;
    loc = glGetUniformBlockIndex(program.programId(), "atmosphereBufferUnit");
    if (loc >= 0) {
        glUniformBlockBinding(program.programId(), loc, ATMOSPHERE_GPU_SLOT);
        locations.atmosphereBufferUnit = ATMOSPHERE_GPU_SLOT;
    } else {
        locations.atmosphereBufferUnit = -1;
    }
#else
    loc = program.uniformLocation("atmosphereBufferUnit");
    if (loc >= 0) {
        locations.atmosphereBufferUnit = loc;
    } else {
        locations.atmosphereBufferUnit = -1;
    }
#endif

    program.release();
}
开发者ID:DaveDubUK,项目名称:hifi,代码行数:62,代码来源:DeferredLightingEffect.cpp


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