本文整理汇总了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");
}