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


C++ DataDescriptor::getNumEntries方法代码示例

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


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

示例1: findUniforms

/**
 * Finds the shader locations of all uniforms and textures from a given material.
 * The input material descriptor has all the possible textures and uniforms
 * that can be used by this shader. (Any material used with this shader
 * will have the same descriptor.)
 *
 * This function uses the descriptor of the input material to find and save
 * the GL shader locations of each texture and uniform. The locations are
 * saved into vectors - mTextureLocs and mUniformLocs. Each vector has an
 * entry for all of the uniforms/textures in the input material
 * (not just the ones used by this shader). If the shader does not
 * reference a particular uniform or texture, that location will be -1.
 * This function must be called after the GL shader program has
 * been selected as the current program.
 * @param material  can be any Material which uses this shader
 * @see #getUniformLoc
 */
void GLShader::findUniforms(const DataDescriptor& desc, int bindingPoint)
{
    std::vector<int>& uniformLocs = mShaderLocs[bindingPoint];

    if (uniformLocs.size() > 0)
    {
        return;
    }
    uniformLocs.resize(desc.getNumEntries(), -1);
    desc.forEachEntry([&](const DataDescriptor::DataEntry& entry) mutable
    {
        if (entry.NotUsed)
        {
            return;
        }
        int loc = glGetUniformLocation(getProgramId(), entry.Name);
        if (loc >= 0)
        {
            uniformLocs[entry.Index] = loc;
#ifdef DEBUG_SHADER
            LOGV("SHADER: program %d uniform %s loc %d", getProgramId(), entry.Name, loc);
#endif
        }
        else
        {
#ifdef DEBUG_SHADER
            LOGV("SHADER: uniform %s has no location in shader %d", entry.Name, getProgramId());
#endif
        }
    });
    checkGLError("GLShader::findUniforms");
}
开发者ID:NolaDonato,项目名称:GearVRf,代码行数:49,代码来源:gl_shader.cpp


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