本文整理汇总了C++中ConstantArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantArray::size方法的具体用法?C++ ConstantArray::size怎么用?C++ ConstantArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantArray
的用法示例。
在下文中一共展示了ConstantArray::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateShader
//----------------------------------------------------------------------------
bool FxCompiler::UpdateShader (Shader* shader, const Program& program,
InputArray& inputs, OutputArray& outputs, ConstantArray& constants,
SamplerArray& samplers)
{
int numInputs = (int)inputs.size();
if (numInputs != shader->GetNumInputs())
{
ReportError("Mismatch in number of inputs.\n");
return false;
}
int numOutputs = (int)outputs.size();
if (numOutputs != shader->GetNumOutputs())
{
ReportError("Mismatch in number of outputs.\n");
return false;
}
int numConstants = (int)constants.size();
if (numConstants != shader->GetNumConstants())
{
ReportError("Mismatch in number of constants.\n");
return false;
}
int numSamplers = (int)samplers.size();
if (numSamplers != shader->GetNumSamplers())
{
ReportError("Mismatch in number of samplers.\n");
return false;
}
std::string message;
int i;
for (i = 0; i < numInputs; ++i)
{
Input& input = inputs[i];
if (input.Name != shader->GetInputName(i))
{
message = "Mismatch in input names '" +
input.Name +
"' and '" +
shader->GetInputName(i);
ReportError(message);
return false;
}
if (input.Type != shader->GetInputType(i))
{
message = "Mismatch in input types '" +
msVTName[input.Type] +
"' and '" +
msVTName[shader->GetInputType(i)];
ReportError(message);
return false;
}
if (input.Semantic != shader->GetInputSemantic(i))
{
message = "Mismatch in input semantics '" +
msVSName[input.Semantic] +
"' and '" +
msVSName[shader->GetInputSemantic(i)];
ReportError(message);
return false;
}
}
for (i = 0; i < numOutputs; ++i)
{
Output& output = outputs[i];
if (output.Name != shader->GetOutputName(i))
{
message = "Mismatch in output names '" +
output.Name +
"' and '" +
shader->GetOutputName(i);
ReportError(message);
return false;
}
if (output.Type != shader->GetOutputType(i))
{
message = "Mismatch in output types '" +
msVTName[output.Type] +
"' and '" +
msVTName[shader->GetOutputType(i)];
ReportError(message);
return false;
}
if (output.Semantic != shader->GetOutputSemantic(i))
{
message = "Mismatch in output semantics '" +
msVSName[output.Semantic] +
"' and '" +
msVSName[shader->GetOutputSemantic(i)];
//.........这里部分代码省略.........
示例2: Process
//----------------------------------------------------------------------------
bool FxCompiler::Process (const Program& program, InputArray& inputs,
OutputArray& outputs, ConstantArray& constants, SamplerArray& samplers)
{
// Variable lines are one of the following:
// var TYPE NAME : $vin.SEMANTIC : inputType : index : 1
// var TYPE NAME : $vout.SEMANTIC : outputType : index : 1
// var TYPE NAME : : c[REGISTER] : index : 1
// var TYPE NAME : : c[REGISTER], NUMREG : index : 1
// var TYPE NAME : : texunit UNITNUMBER : -1 : 1
// The last field is "used", a value of "0" or "1". However, the parser
// stored in 'program' only those variables with a used value "1". The
// all-capitals identifiers are needed by the Wild Magic FX system.
TokenArrays::const_iterator iter = program.Variables.begin();
TokenArrays::const_iterator end = program.Variables.end();
for (/**/; iter != end; ++iter)
{
const TokenArray& tokens = *iter;
// The token array has 10 or 11 tokens.
if (tokens.size() < 10 || tokens.size() > 11)
{
ReportError("Invalid number of tokens", &tokens);
return false;
}
// Get the variable type.
Shader::VariableType vartype = Shader::VT_NONE;
Shader::SamplerType samtype = Shader::ST_NONE;
std::string::size_type begin = tokens[1].find("sampler", 0);
if (begin != std::string::npos)
{
SamplerTypeMap::iterator iter = mSamplerTypes.find(tokens[1]);
if (iter == mSamplerTypes.end())
{
ReportError("Invalid sampler type", &tokens);
return false;
}
samtype = iter->second;
}
else
{
VariableTypeMap::iterator iter = mVariableTypes.find(tokens[1]);
if (iter == mVariableTypes.end())
{
ReportError("Invalid variable type", &tokens);
return false;
}
vartype = iter->second;
}
// Get the variable name.
std::string name = tokens[2];
// Test whether the variable is a singleton or was declared as an
// array. If it is an array, we need to determine how many registers
// it uses. This requires processing variable lines with the same
// variable index.
bool varArray;
begin = name.find("[", 0);
if (begin != std::string::npos)
{
varArray = true;
name = name.substr(0, begin); // strip off "[register]"
}
else
{
varArray = false;
}
// Get the separator before the classifier.
if (tokens[3] != ":")
{
ReportError("Expecting separator character at index 3", &tokens);
return false;
}
// Get the classifier.
begin = tokens[4].find("$vin.", 0);
if (begin != std::string::npos)
{
// The variable is a shader input.
if (!GetInput(tokens, name, vartype, inputs))
{
return false;
}
continue;
}
begin = tokens[4].find("$vout.", 0);
if (begin != std::string::npos)
{
// The variable is a shader output.
if (!GetOutput(tokens, name, vartype, outputs))
{
return false;
}
continue;
}
//.........这里部分代码省略.........