本文整理汇总了C++中CData::GetValueInt方法的典型用法代码示例。如果您正苦于以下问题:C++ CData::GetValueInt方法的具体用法?C++ CData::GetValueInt怎么用?C++ CData::GetValueInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CData
的用法示例。
在下文中一共展示了CData::GetValueInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Compile
//.........这里部分代码省略.........
case GL_FLOAT: oUniform.m_sUniformType = "float"; break;
case GL_FLOAT_VEC2: oUniform.m_sUniformType = "vec2"; break;
case GL_FLOAT_VEC3: oUniform.m_sUniformType = "vec3"; break;
case GL_FLOAT_VEC4: oUniform.m_sUniformType = "vec4"; break;
case GL_INT: oUniform.m_sUniformType = "int"; break;
case GL_BOOL: oUniform.m_sUniformType = "bool"; break;
case GL_FLOAT_MAT4: oUniform.m_sUniformType = "mat4"; break;
case GL_SAMPLER_2D: oUniform.m_sUniformType = "sampler2D"; break;
default: TUnimplemented();
}
}
for (auto it = m_aParameters.begin(); it != m_aParameters.end(); it++)
{
for (size_t j = 0; j < it->second.m_aActions.size(); j++)
{
auto it2 = m_asUniforms.find(it->second.m_aActions[j].m_sName);
TAssert(it2 != m_asUniforms.end());
if (it2 == m_asUniforms.end())
{
TAssert(false);
// A shader specifies a uniform that is not in the linked program.
continue;
}
CShader::CUniform& oUniform = it2->second;
// This is almost cheating
CData d;
d.SetValue(it->second.m_aActions[j].m_sValue);
if (oUniform.m_sUniformType == "float")
it->second.m_aActions[j].m_flValue = d.GetValueFloat();
else if (oUniform.m_sUniformType == "vec2")
it->second.m_aActions[j].m_vec2Value = d.GetValueVector2D();
else if (oUniform.m_sUniformType == "vec3")
it->second.m_aActions[j].m_vecValue = d.GetValueVector();
else if (oUniform.m_sUniformType == "vec4")
it->second.m_aActions[j].m_vec4Value = d.GetValueVector4D();
else if (oUniform.m_sUniformType == "int")
it->second.m_aActions[j].m_iValue = d.GetValueInt();
else if (oUniform.m_sUniformType == "bool")
it->second.m_aActions[j].m_bValue = d.GetValueBool();
else if (oUniform.m_sUniformType == "mat4")
{
TUnimplemented();
}
else if (oUniform.m_sUniformType == "sampler2D")
{
// No op.
}
else
TUnimplemented();
}
}
for (auto it = m_aDefaults.begin(); it != m_aDefaults.end(); it++)
{
auto it2 = m_asUniforms.find(it->first);
TAssert(it2 != m_asUniforms.end());
if (it2 == m_asUniforms.end())
{
TAssert(false);
// A shader specifies a default for a uniform that is not in the linked program.
continue;
}
CShader::CUniform& oUniform = it2->second;
oUniform.m_pDefault = &it->second;
// Again with the cheating.
CData d;
d.SetValue(it->second.m_sValue);
if (oUniform.m_sUniformType == "float")
it->second.m_flValue = d.GetValueFloat();
else if (oUniform.m_sUniformType == "vec2")
it->second.m_vec2Value = d.GetValueVector2D();
else if (oUniform.m_sUniformType == "vec3")
it->second.m_vecValue = d.GetValueVector();
else if (oUniform.m_sUniformType == "vec4")
it->second.m_vec4Value = d.GetValueVector4D();
else if (oUniform.m_sUniformType == "int")
it->second.m_iValue = d.GetValueInt();
else if (oUniform.m_sUniformType == "bool")
it->second.m_bValue = d.GetValueBool();
else if (oUniform.m_sUniformType == "mat4")
{
TUnimplemented();
}
else if (oUniform.m_sUniformType == "sampler2D")
{
TUnimplemented(); // Can't set a default texture... yet.
}
else
TUnimplemented();
}
return true;
}
示例2: ReadLesson
void CInstructor::ReadLesson(const class CData* pData)
{
tstring sLessonName = pData->GetValueString();
if (!sLessonName.length())
{
TError("Found a lesson with no name.\n");
return;
}
CLesson* pLesson = new CLesson(this, sLessonName);
m_apLessons[sLessonName] = pLesson;
for (size_t i = 0; i < pData->GetNumChildren(); i++)
{
CData* pChildData = pData->GetChild(i);
if (pChildData->GetKey() == "Position")
{
tstring sPosition = pChildData->GetValueString();
if (sPosition == "top-center")
pLesson->m_iPosition = POSITION_TOPCENTER;
else if (sPosition == "top-left")
pLesson->m_iPosition = POSITION_TOPLEFT;
else if (sPosition == "left")
pLesson->m_iPosition = POSITION_LEFT;
}
else if (pChildData->GetKey() == "Width")
pLesson->m_iWidth = pChildData->GetValueInt();
else if (pChildData->GetKey() == "Next")
pLesson->m_sNextLesson = pChildData->GetValueString();
else if (pChildData->GetKey() == "Text")
pLesson->m_sText = pChildData->GetValueString();
else if (pChildData->GetKey() == "SlideAmount")
pLesson->m_flSlideAmount = pChildData->GetValueFloat();
else if (pChildData->GetKey() == "SlideX")
pLesson->m_bSlideX = pChildData->GetValueBool();
else if (pChildData->GetKey() == "Rotation")
pLesson->m_bRotation = pChildData->GetValueBool();
else if (pChildData->GetKey() == "Output")
ReadLessonOutput(pChildData, pLesson);
else if (pChildData->GetKey() == "Priority")
pLesson->m_iPriority = pChildData->GetValueInt();
else if (pChildData->GetKey() == "LessonType")
{
tstring sLessonType = pChildData->GetValueString();
if (sLessonType == "button")
pLesson->m_iLessonType = CLesson::LESSON_BUTTON;
else if (sLessonType == "info")
pLesson->m_iLessonType = CLesson::LESSON_INFO;
else if (sLessonType == "environment")
pLesson->m_iLessonType = CLesson::LESSON_ENVIRONMENT;
}
else if (pChildData->GetKey() == "LearningMethod")
{
tstring sLearningMethod = pChildData->GetValueString();
if (sLearningMethod == "displaying")
pLesson->m_iLearningMethod = CLesson::LEARN_DISPLAYING;
else if (sLearningMethod == "display")
pLesson->m_iLearningMethod = CLesson::LEARN_DISPLAYING;
else if (sLearningMethod == "performing")
pLesson->m_iLearningMethod = CLesson::LEARN_PERFORMING;
else if (sLearningMethod == "perform")
pLesson->m_iLearningMethod = CLesson::LEARN_PERFORMING;
}
else if (pChildData->GetKey() == "TimesToLearn")
pLesson->m_iTimesToLearn = pChildData->GetValueInt();
else if (pChildData->GetKey() == "Conditions")
pLesson->m_pfnConditions = Game_GetInstructorConditions(pChildData->GetValueString()); // A dirty hack, but not a scary one.
}
}