本文整理汇总了C++中ParameterPtr::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterPtr::getName方法的具体用法?C++ ParameterPtr::getName怎么用?C++ ParameterPtr::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterPtr
的用法示例。
在下文中一共展示了ParameterPtr::getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeOutParameters
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeOutParameters(std::ostream& os, Function* function, GpuProgramType gpuType)
{
const ShaderParameterList& outParams = function->getOutputParameters();
ShaderParameterConstIterator itParam = outParams.begin();
ShaderParameterConstIterator itParamEnd = outParams.end();
for ( ; itParam != itParamEnd; ++itParam)
{
ParameterPtr pParam = *itParam;
if(gpuType == GPT_VERTEX_PROGRAM)
{
// GLSL vertex program has to write always gl_Position (but this is also deprecated after version 130)
if(pParam->getContent() == Parameter::SPC_POSITION_PROJECTIVE_SPACE)
{
mInputToGLStatesMap[pParam->getName()] = "gl_Position";
}
else
{
// After GLSL 1.20 varying is deprecated
if(mGLSLVersion <= 120)
{
os << "varying\t";
}
else
{
os << "out\t";
}
os << mGpuConstTypeMap[pParam->getType()];
os << "\t";
os << pParam->getName();
if (pParam->isArray() == true)
{
os << "[" << pParam->getSize() << "]";
}
os << ";" << std::endl;
}
}
else if(gpuType == GPT_FRAGMENT_PROGRAM &&
pParam->getSemantic() == Parameter::SPS_COLOR)
{
// GLSL fragment program has to write always gl_FragColor (but this is also deprecated after version 130)
// Always add gl_FragColor as an output. The name is for compatibility.
if(mGLSLVersion <= 130)
{
mInputToGLStatesMap[pParam->getName()] = "gl_FragColor";
}
else
{
os << "out vec4 fragColour;" << std::endl;
mInputToGLStatesMap[pParam->getName()] = "fragColour";
}
}
}
}
示例2: writeFunctionParameter
//-----------------------------------------------------------------------
void CGProgramWriter::writeFunctionParameter(std::ostream& os, ParameterPtr parameter)
{
os << mGpuConstTypeMap[parameter->getType()];
os << "\t";
os << parameter->getName();
if (parameter->isArray() == true)
{
os << "[" << parameter->getSize() << "]";
}
if (parameter->getSemantic() != Parameter::SPS_UNKNOWN)
{
os << " : ";
os << mParamSemanticMap[parameter->getSemantic()];
if (parameter->getSemantic() != Parameter::SPS_POSITION &&
parameter->getSemantic() != Parameter::SPS_NORMAL &&
parameter->getSemantic() != Parameter::SPS_TANGENT &&
parameter->getSemantic() != Parameter::SPS_BLEND_INDICES &&
parameter->getSemantic() != Parameter::SPS_BLEND_WEIGHTS &&
(!(parameter->getSemantic() == Parameter::SPS_COLOR && parameter->getIndex() == 0)) &&
parameter->getIndex() >= 0)
{
os << StringConverter::toString(parameter->getIndex()).c_str();
}
}
}
示例3: writeLocalParameter
//-----------------------------------------------------------------------
void CGProgramWriter::writeLocalParameter(std::ostream& os, ParameterPtr parameter)
{
os << mGpuConstTypeMap[parameter->getType()];
os << "\t";
os << parameter->getName();
if (parameter->isArray() == true)
{
os << "[" << parameter->getSize() << "]";
}
}
示例4: addOutputParameter
//-----------------------------------------------------------------------------
void Function::addOutputParameter(ParameterPtr parameter)
{
// Check that parameter with the same semantic and index in output parameters list.
if (getParameterBySemantic(mOutputParameters, parameter->getSemantic(), parameter->getIndex()).get() != NULL)
{
OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS,
"Parameter <" + parameter->getName() + "> has equal sematic parameter in function <" + getName() + ">",
"Function::addOutputParameter" );
}
addParameter(mOutputParameters, parameter);
}
示例5: addParameter
//-----------------------------------------------------------------------------
void Function::addParameter(ShaderParameterList& parameterList, ParameterPtr parameter)
{
// Check that parameter with the same name doest exist in input parameters list.
if (getParameterByName(mInputParameters, parameter->getName()).get() != NULL)
{
OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS,
"Parameter <" + parameter->getName() + "> already declared in function <" + getName() + ">",
"Function::addParameter" );
}
// Check that parameter with the same name doest exist in output parameters list.
if (getParameterByName(mOutputParameters, parameter->getName()).get() != NULL)
{
OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS,
"Parameter <" + parameter->getName() + "> already declared in function <" + getName() + ">",
"Function::addParameter" );
}
// Add to given parameters list.
parameterList.push_back(parameter);
}
示例6: writeFunctionParameter
//-----------------------------------------------------------------------
void HLSLProgramWriter::writeFunctionParameter(std::ostream& os, ParameterPtr parameter)
{
os << mGpuConstTypeMap[parameter->getType()];
os << "\t";
os << parameter->getName();
if (parameter->getSemantic() != Parameter::SPS_UNKNOWN)
{
os << " : ";
os << mParamSemanticMap[parameter->getSemantic()];
if (parameter->getSemantic() != Parameter::SPS_POSITION &&
parameter->getSemantic() != Parameter::SPS_NORMAL &&
(!(parameter->getSemantic() == Parameter::SPS_COLOR && parameter->getIndex() == 0)) &&
parameter->getIndex() >= 0)
{
os << StringConverter::toString(parameter->getIndex()).c_str();
}
}
}
示例7: writeInputParameters
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeInputParameters(std::ostream& os, Function* function, GpuProgramType gpuType)
{
const ShaderParameterList& inParams = function->getInputParameters();
ShaderParameterConstIterator itParam = inParams.begin();
ShaderParameterConstIterator itParamEnd = inParams.end();
for ( ; itParam != itParamEnd; ++itParam)
{
ParameterPtr pParam = *itParam;
Parameter::Content paramContent = pParam->getContent();
String paramName = pParam->getName();
if (gpuType == GPT_FRAGMENT_PROGRAM)
{
// push fragment inputs they all could be written (in glsl you can not write
// input params in the fragment program)
mFragInputParams.push_back(paramName);
// In the vertex and fragment program the variable names must match.
// Unfortunately now the input params are prefixed with an 'i' and output params with 'o'.
// Thats why we are using a map for name mapping (we rename the params which are used in function atoms).
paramName.replace(paramName.begin(), paramName.begin() + 1, "o");
mInputToGLStatesMap[pParam->getName()] = paramName;
// After GLSL 1.20 varying is deprecated
if(mGLSLVersion <= 120)
{
os << "varying\t";
}
else
{
os << "in\t";
}
os << mGpuConstTypeMap[pParam->getType()];
os << "\t";
os << paramName;
os << ";" << std::endl;
}
else if (gpuType == GPT_VERTEX_PROGRAM &&
mContentToPerVertexAttributes.find(paramContent) != mContentToPerVertexAttributes.end())
{
// Due the fact that glsl does not have register like cg we have to rename the params
// according there content.
mInputToGLStatesMap[paramName] = mContentToPerVertexAttributes[paramContent];
// After GLSL 1.40 attribute is deprecated
if (mGLSLVersion >= 140)
{
os << "in\t";
}
else
{
os << "attribute\t";
}
// all uv texcoords passed by ogre are vec4
if (paramContent == Parameter::SPC_TEXTURE_COORDINATE0 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE1 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE2 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE3 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE4 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE5 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE6 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE7 )
{
os << "vec4";
}
else
{
os << mGpuConstTypeMap[pParam->getType()];
}
os << "\t";
os << mContentToPerVertexAttributes[paramContent];
os << ";" << std::endl;
}
else if(paramContent == Parameter::SPC_COLOR_DIFFUSE)
{
mInputToGLStatesMap[paramName] = "gl_Color";
}
else if(paramContent == Parameter::SPC_COLOR_SPECULAR)
{
mInputToGLStatesMap[paramName] = "gl_SecondaryColor";
}
else
{
os << "uniform \t ";
os << mGpuConstTypeMap[pParam->getType()];
os << "\t";
os << paramName;
os << ";" << std::endl;
}
}
}
示例8: 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
//.........这里部分代码省略.........
示例9: generateLocalSplitParameters
//-----------------------------------------------------------------------------
void ProgramProcessor::generateLocalSplitParameters(Function* func, GpuProgramType progType,
MergeParameterList& mergedParams,
ShaderParameterList& splitParams, LocalParameterMap& localParamsMap)
{
// No split params created.
if (splitParams.size() == 0)
return;
// Create the local parameters + map from source to local.
for (unsigned int i=0; i < splitParams.size(); ++i)
{
ParameterPtr srcParameter = splitParams[i];
ParameterPtr localParameter = func->resolveLocalParameter(srcParameter->getSemantic(), srcParameter->getIndex(), "lsplit_" + srcParameter->getName(), srcParameter->getType());
localParamsMap[srcParameter.get()] = localParameter;
}
int invocationCounter = 0;
// Establish link between the local parameter to the merged parameter.
for (unsigned int i=0; i < mergedParams.size(); ++i)
{
MergeParameter& curMergeParameter = mergedParams[i];
for (unsigned int p=0; p < curMergeParameter.getSourceParameterCount(); ++p)
{
ParameterPtr srcMergedParameter = curMergeParameter.getSourceParameter(p);
LocalParameterMap::iterator itFind = localParamsMap.find(srcMergedParameter.get());
// Case the source parameter is split parameter.
if (itFind != localParamsMap.end())
{
// Case it is the vertex shader -> assign the local parameter to the output merged parameter.
if (progType == GPT_VERTEX_PROGRAM)
{
FunctionInvocation* curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, FFP_VS_POST_PROCESS, invocationCounter++);
curFuncInvocation->pushOperand(itFind->second, Operand::OPS_IN, curMergeParameter.getSourceParameterMask(p));
curFuncInvocation->pushOperand(curMergeParameter.getDestinationParameter(Operand::OPS_OUT, i), Operand::OPS_OUT, curMergeParameter.getDestinationParameterMask(p));
func->addAtomInstance(curFuncInvocation);
}
else if (progType == GPT_FRAGMENT_PROGRAM)
{
FunctionInvocation* curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, FFP_PS_PRE_PROCESS, invocationCounter++);
curFuncInvocation->pushOperand(curMergeParameter.getDestinationParameter(Operand::OPS_IN, i), Operand::OPS_IN, curMergeParameter.getDestinationParameterMask(p));
curFuncInvocation->pushOperand(itFind->second, Operand::OPS_OUT, curMergeParameter.getSourceParameterMask(p));
func->addAtomInstance(curFuncInvocation);
}
}
}
}
}
示例10: writeSourceCode
//-----------------------------------------------------------------------
void HLSLProgramWriter::writeSourceCode(std::ostream& os, Program* program)
{
const ShaderFunctionList& functionList = program->getFunctions();
ShaderFunctionConstIterator itFunction;
const UniformParameterList& parameterList = program->getParameters();
UniformParameterConstIterator itUniformParam = parameterList.begin();
// Generate source code header.
writeProgramTitle(os, program);
os << std::endl;
// Generate dependencies.
writeProgramDependencies(os, program);
os << std::endl;
// Generate global variable code.
writeUniformParametersTitle(os, program);
os << std::endl;
for (itUniformParam=parameterList.begin(); itUniformParam != parameterList.end(); ++itUniformParam)
{
writeUniformParameter(os, *itUniformParam);
os << ";" << std::endl;
}
os << std::endl;
// Write program function(s).
for (itFunction=functionList.begin(); itFunction != functionList.end(); ++itFunction)
{
Function* curFunction = *itFunction;
bool needToTranslateHlsl4Color = false;
ParameterPtr colorParameter;
writeFunctionTitle(os, curFunction);
writeFunctionDeclaration(os, curFunction, needToTranslateHlsl4Color, colorParameter);
os << "{" << std::endl;
// Write local parameters.
const ShaderParameterList& localParams = curFunction->getLocalParameters();
ShaderParameterConstIterator itParam = localParams.begin();
for (; itParam != localParams.end(); ++itParam)
{
os << "\t";
writeLocalParameter(os, *itParam);
os << ";" << std::endl;
}
// translate hlsl 4 color parameter if needed
if(needToTranslateHlsl4Color)
{
os << "\t";
writeLocalParameter(os, colorParameter);
os << ";" << std::endl;
os << std::endl <<"\tFFP_Assign(iHlsl4Color_0, " << colorParameter->getName() << ");" << std::endl;
}
// Sort and write function atoms.
curFunction->sortAtomInstances();
const FunctionAtomInstanceList& atomInstances = curFunction->getAtomInstances();
FunctionAtomInstanceConstIterator itAtom;
for (itAtom=atomInstances.begin(); itAtom != atomInstances.end(); ++itAtom)
{
writeAtomInstance(os, *itAtom);
}
os << "}" << std::endl;
}
os << std::endl;
}
示例11: writeLocalParameter
//-----------------------------------------------------------------------
void HLSLProgramWriter::writeLocalParameter(std::ostream& os, ParameterPtr parameter)
{
os << mGpuConstTypeMap[parameter->getType()];
os << "\t";
os << parameter->getName();
}
示例12: writeOutParameters
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeOutParameters(std::ostream& os, Function* function, GpuProgramType gpuType)
{
const ShaderParameterList& outParams = function->getOutputParameters();
ShaderParameterConstIterator itParam = outParams.begin();
ShaderParameterConstIterator itParamEnd = outParams.end();
for ( ; itParam != itParamEnd; ++itParam)
{
ParameterPtr pParam = *itParam;
if(gpuType == GPT_VERTEX_PROGRAM)
{
// GLSL vertex program has to write always gl_Position (but this is also deprecated after version 130)
if(pParam->getContent() == Parameter::SPC_POSITION_PROJECTIVE_SPACE)
{
mInputToGLStatesMap[pParam->getName()] = "gl_Position";
}
else
{
// After GLSL 1.20 varying is deprecated
if(mGLSLVersion <= 120)
{
os << "varying\t";
}
else
{
os << "out\t";
}
os << mGpuConstTypeMap[pParam->getType()];
os << "\t";
os << pParam->getName();
if (pParam->isArray() == true)
{
os << "[" << pParam->getSize() << "]";
}
os << ";" << std::endl;
}
}
else if(gpuType == GPT_FRAGMENT_PROGRAM &&
pParam->getSemantic() == Parameter::SPS_COLOR)
{
// GLSL fragment program has to write always gl_FragColor (but this is also deprecated after version 130)
// Always add gl_FragColor as an output. The name is for compatibility.
if(mGLSLVersion <= 130)
{
mInputToGLStatesMap[pParam->getName()] = "gl_FragColor";
}
else
{
os << "out vec4 fragColour;" << std::endl;
mInputToGLStatesMap[pParam->getName()] = "fragColour";
}
}
}
if(gpuType == GPT_VERTEX_PROGRAM)
{
// Special case where gl_Position needs to be redeclared
if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS) &&
mGLSLVersion >= 150)
{
os << "out gl_PerVertex\n{\nvec4 gl_Position;\nfloat gl_PointSize;\nfloat gl_ClipDistance[];\n};\n" << std::endl;
}
}
}