本文整理汇总了C++中FunctionInvocation::getFunctionName方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionInvocation::getFunctionName方法的具体用法?C++ FunctionInvocation::getFunctionName怎么用?C++ FunctionInvocation::getFunctionName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionInvocation
的用法示例。
在下文中一共展示了FunctionInvocation::getFunctionName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool FunctionInvocation::FunctionInvocationLessThan::operator ()(FunctionInvocation const& lhs, FunctionInvocation const& rhs) const
{
// Check the function names first
if (lhs.getFunctionName() < rhs.getFunctionName())
return true;
// Next check the return type
if (lhs.getReturnType() < rhs.getReturnType())
return true;
// Check the number of operands
if (lhs.mOperands.size() < rhs.mOperands.size())
return true;
// Now that we've gotten past the two quick tests, iterate over operands
// Check the semantic and type. The operands must be in the same order as well.
OperandVector::const_iterator itLHSOps = lhs.mOperands.begin();
OperandVector::const_iterator itRHSOps = rhs.mOperands.begin();
for ( ; itLHSOps != lhs.mOperands.end(), itRHSOps != rhs.mOperands.end(); ++itLHSOps, ++itRHSOps)
{
if (itLHSOps->getSemantic() < itRHSOps->getSemantic())
return true;
if (itLHSOps->getParameter()->getType() < itRHSOps->getParameter()->getType())
return true;
}
return false;
}
示例2:
bool FunctionInvocation::FunctionInvocationCompare::operator ()(FunctionInvocation const& lhs, FunctionInvocation const& rhs) const
{
// Check the function names first
if (lhs.getFunctionName() != rhs.getFunctionName())
return false;
// Next check the return type
if (lhs.getReturnType() != rhs.getReturnType())
return false;
// Check the number of operands
if (lhs.mOperands.size() != rhs.mOperands.size())
return false;
// Now that we've gotten past the two quick tests, iterate over operands
// Check the semantic and type. The operands must be in the same order as well.
OperandVector::const_iterator itLHSOps = lhs.mOperands.begin();
OperandVector::const_iterator itRHSOps = rhs.mOperands.begin();
for ( ; ((itLHSOps != lhs.mOperands.end()) && (itRHSOps != rhs.mOperands.end())); ++itLHSOps, ++itRHSOps)
{
if (itLHSOps->getSemantic() != itRHSOps->getSemantic())
return false;
GpuConstantType leftType = itLHSOps->getParameter()->getType();
GpuConstantType rightType = itRHSOps->getParameter()->getType();
if (Ogre::Root::getSingletonPtr()->getRenderSystem()->getName().find("OpenGL ES 2") != String::npos)
{
if (leftType == GCT_SAMPLER1D)
leftType = GCT_SAMPLER2D;
if (rightType == GCT_SAMPLER1D)
rightType = GCT_SAMPLER2D;
}
// If a swizzle mask is being applied to the parameter, generate the GpuConstantType to
// perform the parameter type comparison the way that the compiler will see it.
if ((itLHSOps->getFloatCount(itLHSOps->getMask()) > 0) ||
(itRHSOps->getFloatCount(itRHSOps->getMask()) > 0))
{
if (itLHSOps->getFloatCount(itLHSOps->getMask()) > 0)
{
leftType = (GpuConstantType)((itLHSOps->getParameter()->getType() - itLHSOps->getParameter()->getType()) +
itLHSOps->getFloatCount(itLHSOps->getMask()));
}
if (itRHSOps->getFloatCount(itRHSOps->getMask()) > 0)
{
rightType = (GpuConstantType)((itRHSOps->getParameter()->getType() - itRHSOps->getParameter()->getType()) +
itRHSOps->getFloatCount(itRHSOps->getMask()));
}
}
if (leftType != rightType)
return false;
}
// Passed all tests, they are the same
return true;
}
示例3:
bool FunctionInvocation::FunctionInvocationLessThan::operator ()(FunctionInvocation const& lhs, FunctionInvocation const& rhs) const
{
// Check the function names first
// Adding an exception to std::string sorting. I feel that functions beginning with an underscore should be placed before
// functions beginning with an alphanumeric character. By default strings are sorted based on the ASCII value of each character.
// Underscores have an ASCII value in between capital and lowercase characters. This is why the exception is needed.
if (lhs.getFunctionName() < rhs.getFunctionName())
{
if(rhs.getFunctionName().at(0) == '_')
return false;
else
return true;
}
if (lhs.getFunctionName() > rhs.getFunctionName())
{
if(lhs.getFunctionName().at(0) == '_')
return true;
else
return false;
}
// Next check the return type
if (lhs.getReturnType() < rhs.getReturnType())
return true;
if (lhs.getReturnType() > rhs.getReturnType())
return false;
// Check the number of operands
if (lhs.mOperands.size() < rhs.mOperands.size())
return true;
if (lhs.mOperands.size() > rhs.mOperands.size())
return false;
// Now that we've gotten past the two quick tests, iterate over operands
// Check the semantic and type. The operands must be in the same order as well.
OperandVector::const_iterator itLHSOps = lhs.mOperands.begin();
OperandVector::const_iterator itRHSOps = rhs.mOperands.begin();
for ( ; itLHSOps != lhs.mOperands.end(), itRHSOps != rhs.mOperands.end(); ++itLHSOps, ++itRHSOps)
{
if (itLHSOps->getSemantic() < itRHSOps->getSemantic())
return true;
if (itLHSOps->getSemantic() > itRHSOps->getSemantic())
return false;
if (itLHSOps->getParameter()->getType() < itRHSOps->getParameter()->getType())
return true;
if (itLHSOps->getParameter()->getType() > itRHSOps->getParameter()->getType())
return false;
}
return true;
}
示例4: 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.
//.........这里部分代码省略.........
示例5: writeSourceCode
//.........这里部分代码省略.........
// 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
localOs << "\t" << pFuncInvoc->getFunctionName() << "(";
ushort curIndLevel = 0;
for (; itOperand != itOperandEnd; )
{
Operand op = *itOperand;
Operand::OpSemantic opSemantic = op.getSemantic();
String paramName = op.getParameter()->getName();
Parameter::Content content = op.getParameter()->getContent();
if (opSemantic == Operand::OPS_OUT || opSemantic == Operand::OPS_INOUT)
{
// Is the written parameter a varying
bool isVarying = false;
// Check if we write to an varying because the are only readable in fragment programs
if (gpuType == GPT_FRAGMENT_PROGRAM)
{
StringVector::iterator itFound = std::find(mFragInputParams.begin(), mFragInputParams.end(), paramName);
if(itFound != mFragInputParams.end())
{
// Declare the copy variable
String newVar = "local_" + paramName;
String tempVar = paramName;
isVarying = true;
// We stored the original values in the mFragInputParams thats why we have to replace the first var with o
// because all vertex output vars are prefixed with o in glsl the name has to match in the fragment program.
tempVar.replace(tempVar.begin(), tempVar.begin() + 1, "o");
// Declare the copy variable and assign the original
os << "\t" << mGpuConstTypeMap[op.getParameter()->getType()] << " " << newVar << " = " << tempVar << ";\n" << std::endl;