本文整理汇总了C++中ParameterPtr::getContent方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterPtr::getContent方法的具体用法?C++ ParameterPtr::getContent怎么用?C++ ParameterPtr::getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterPtr
的用法示例。
在下文中一共展示了ParameterPtr::getContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: resolveInputParameter
//-----------------------------------------------------------------------------
ParameterPtr Function::resolveInputParameter(Parameter::Semantic semantic,
int index,
const Parameter::Content content,
GpuConstantType type)
{
ParameterPtr param;
// Check if desired parameter already defined.
param = getParameterByContent(mInputParameters, content, type);
if (param.get() != NULL)
return param;
// Case we have to create new parameter.
if (index == -1)
{
index = 0;
// Find the next available index of the target semantic.
ShaderParameterIterator it;
for (it = mInputParameters.begin(); it != mInputParameters.end(); ++it)
{
if ((*it)->getSemantic() == semantic)
{
index++;
}
}
}
else
{
// Check if desired parameter already defined.
param = getParameterBySemantic(mInputParameters, semantic, index);
if (param.get() != NULL && param->getContent() == content)
{
if (param->getType() == type)
{
return param;
}
else
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Can not resolve parameter - semantic: " + StringConverter::toString(semantic) + " - index: " + StringConverter::toString(index) + " due to type mismatch. Function <" + getName() + ">",
"Function::resolveInputParameter" );
}
}
}
// No parameter found -> create new one.
switch (semantic)
{
case Parameter::SPS_POSITION:
assert(type == GCT_FLOAT4);
param = ParameterFactory::createInPosition(index);
break;
case Parameter::SPS_BLEND_WEIGHTS:
assert(type == GCT_FLOAT4);
param = ParameterFactory::createInWeights(index);
break;
case Parameter::SPS_BLEND_INDICES:
assert(type == GCT_FLOAT4);
param = ParameterFactory::createInIndices(index);
break;
case Parameter::SPS_NORMAL:
assert(type == GCT_FLOAT3);
param = ParameterFactory::createInNormal(index);
break;
case Parameter::SPS_COLOR:
assert(type == GCT_FLOAT4);
param = ParameterFactory::createInColor(index);
break;
case Parameter::SPS_TEXTURE_COORDINATES:
param = ParameterFactory::createInTexcoord(type, index, content);
break;
case Parameter::SPS_BINORMAL:
assert(type == GCT_FLOAT3);
param = ParameterFactory::createInBiNormal(index);
break;
case Parameter::SPS_TANGENT:
assert(type == GCT_FLOAT3);
param = ParameterFactory::createInTangent(index);
break;
case Parameter::SPS_UNKNOWN:
break;
}
if (param.get() != NULL)
addInputParameter(param);
return param;
}
示例3: 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;
}
}
}
示例4: 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;
}
}
}