本文整理汇总了C++中FunctionInvocation::getOperandList方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionInvocation::getOperandList方法的具体用法?C++ FunctionInvocation::getOperandList怎么用?C++ FunctionInvocation::getOperandList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionInvocation
的用法示例。
在下文中一共展示了FunctionInvocation::getOperandList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildParameterReferenceMap
//-----------------------------------------------------------------------------
void ProgramProcessor::buildParameterReferenceMap(FunctionAtomInstanceList& funcAtomList, ParameterOperandMap& paramsRefMap)
{
FunctionAtomInstanceIterator it = funcAtomList.begin();
FunctionAtomInstanceIterator itEnd = funcAtomList.end();
for (; it != itEnd; ++it)
{
FunctionAtom* curAtom = *it;
// Deal only with function invocations.
if (curAtom->getFunctionAtomType() == FunctionInvocation::Type)
{
FunctionInvocation* curFuncInvocation = static_cast<FunctionInvocation*>(curAtom);
FunctionInvocation::OperandVector& funcOperands = curFuncInvocation->getOperandList();
for (unsigned int op=0; op < funcOperands.size(); ++op)
{
Operand& curOperand = funcOperands[op];
paramsRefMap[curOperand.getParameter().get()].push_back(&curOperand);
}
}
}
}
示例2: writeForwardDeclarations
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeForwardDeclarations(std::ostream& os, Program* program)
{
os << "//-----------------------------------------------------------------------------" << std::endl;
os << "// FORWARD DECLARATIONS" << std::endl;
os << "//-----------------------------------------------------------------------------" << std::endl;
StringVector forwardDecl; // holds all generated function declarations
const ShaderFunctionList& functionList = program->getFunctions();
ShaderFunctionConstIterator itFunction;
// Iterate over all functions in the current program (in our case this is always the main() function)
for ( itFunction = functionList.begin(); itFunction != functionList.end(); ++itFunction)
{
Function* curFunction = *itFunction;
const FunctionAtomInstanceList& atomInstances = curFunction->getAtomInstances();
FunctionAtomInstanceConstIterator itAtom = atomInstances.begin();
FunctionAtomInstanceConstIterator itAtomEnd = atomInstances.end();
// Now iterate over all function atoms
for ( ; itAtom != itAtomEnd; ++itAtom)
{
// Skip non function invocation atoms.
if ((*itAtom)->getFunctionAtomType() != FunctionInvocation::Type)
continue;
FunctionInvocation* pFuncInvoc = static_cast<FunctionInvocation*>(*itAtom);
FunctionInvocation::OperandVector::iterator itOperator = pFuncInvoc->getOperandList().begin();
FunctionInvocation::OperandVector::iterator itOperatorEnd = pFuncInvoc->getOperandList().end();
// Start with function declaration
String funcDecl = pFuncInvoc->getReturnType() + " " + pFuncInvoc->getFunctionName() + "(";
// Now iterate overall operands
for (; itOperator != itOperatorEnd; )
{
ParameterPtr pParam = (*itOperator).getParameter();
Operand::OpSemantic opSemantic = (*itOperator).getSemantic();
int opMask = (*itOperator).getMask();
GpuConstantType gpuType = GCT_UNKNOWN;
// Write the semantic in, out, inout
switch(opSemantic)
{
case Operand::OPS_IN:
funcDecl += "in ";
break;
case Operand::OPS_OUT:
funcDecl += "out ";
break;
case Operand::OPS_INOUT:
funcDecl += "inout ";
break;
default:
break;
}
// Swizzle masks are only defined for types like vec2, vec3, vec4.
if (opMask == Operand::OPM_ALL)
{
gpuType = pParam->getType();
}
else
{
// Now we have to convert the mask to operator
gpuType = Operand::getGpuConstantType(opMask);
}
// We need a valid type otherwise glsl compilation will not work
if (gpuType == GCT_UNKNOWN)
{
OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR,
"Can not convert Operand::OpMask to GpuConstantType",
"GLSLProgramWriter::writeForwardDeclarations" );
}
// Write the operand type.
funcDecl += mGpuConstTypeMap[gpuType];
++itOperator;
//move over all operators with indirection
while ((itOperator != itOperatorEnd) && (itOperator->getIndirectionLevel() != 0))
{
++itOperator;
}
// Prepare for the next operand
if (itOperator != itOperatorEnd)
{
funcDecl += ", ";
}
}
// Write function call closer.
funcDecl += ");\n";
// Push the generated declaration into the vector
// duplicate declarations will be removed later.
//.........这里部分代码省略.........
示例3: writeSourceCode
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeSourceCode(std::ostream& os, Program* program)
{
GpuProgramType gpuType = program->getType();
if(gpuType == GPT_GEOMETRY_PROGRAM)
{
OGRE_EXCEPT( Exception::ERR_NOT_IMPLEMENTED,
"Geometry Program not supported in GLSL writer ",
"GLSLProgramWriter::writeSourceCode" );
}
// Clear out old input params
mFragInputParams.clear();
const ShaderFunctionList& functionList = program->getFunctions();
ShaderFunctionConstIterator itFunction;
const UniformParameterList& parameterList = program->getParameters();
UniformParameterConstIterator itUniformParam = parameterList.begin();
// Write the current version (this force the driver to more fulfill the glsl standard)
os << "#version "<< mGLSLVersion << std::endl;
// Generate source code header.
writeProgramTitle(os, program);
os<< std::endl;
// Write forward declarations
writeForwardDeclarations(os, program);
os<< std::endl;
// Generate global variable code.
writeUniformParametersTitle(os, program);
os << std::endl;
// Write the uniforms
for (itUniformParam = parameterList.begin(); itUniformParam != parameterList.end(); ++itUniformParam)
{
ParameterPtr pUniformParam = *itUniformParam;
os << "uniform\t";
os << mGpuConstTypeMap[pUniformParam->getType()];
os << "\t";
os << pUniformParam->getName();
if (pUniformParam->isArray() == true)
{
os << "[" << pUniformParam->getSize() << "]";
}
os << ";" << std::endl;
}
os << std::endl;
// Write program function(s).
for (itFunction=functionList.begin(); itFunction != functionList.end(); ++itFunction)
{
Function* curFunction = *itFunction;
writeFunctionTitle(os, curFunction);
// Clear output mapping this map is used when we use
// glsl built in types like gl_Color for example
mInputToGLStatesMap.clear();
// Write inout params and fill mInputToGLStatesMap
writeInputParameters(os, curFunction, gpuType);
writeOutParameters(os, curFunction, gpuType);
// The function name must always main.
os << "void main(void) {" << std::endl;
// Write local parameters.
const ShaderParameterList& localParams = curFunction->getLocalParameters();
ShaderParameterConstIterator itParam = localParams.begin();
ShaderParameterConstIterator itParamEnd = localParams.end();
for (; itParam != itParamEnd; ++itParam)
{
os << "\t";
writeLocalParameter(os, *itParam);
os << ";" << std::endl;
}
os << std::endl;
// Sort function atoms.
curFunction->sortAtomInstances();
const FunctionAtomInstanceList& atomInstances = curFunction->getAtomInstances();
FunctionAtomInstanceConstIterator itAtom = atomInstances.begin();
FunctionAtomInstanceConstIterator itAtomEnd = atomInstances.end();
for (; itAtom != itAtomEnd; ++itAtom)
{
FunctionInvocation* pFuncInvoc = (FunctionInvocation*)*itAtom;
FunctionInvocation::OperandVector::iterator itOperand = pFuncInvoc->getOperandList().begin();
FunctionInvocation::OperandVector::iterator itOperandEnd = pFuncInvoc->getOperandList().end();
// Local string stream
StringStream localOs;
// Write function name
//.........这里部分代码省略.........