本文整理汇总了C++中Shader::GetPath方法的典型用法代码示例。如果您正苦于以下问题:C++ Shader::GetPath方法的具体用法?C++ Shader::GetPath怎么用?C++ Shader::GetPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shader
的用法示例。
在下文中一共展示了Shader::GetPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CacheResource
/// @copydoc ResourceHandler::CacheResource()
bool ShaderVariantResourceHandler::CacheResource(
ObjectPreprocessor* pObjectPreprocessor,
Resource* pResource,
const String& rSourceFilePath )
{
HELIUM_ASSERT( pObjectPreprocessor );
HELIUM_ASSERT( pResource );
ShaderVariant* pVariant = Reflect::AssertCast< ShaderVariant >( pResource );
// Parse the shader type and user option index from the variant name.
Name variantName = pVariant->GetName();
const tchar_t* pVariantNameString = *variantName;
HELIUM_ASSERT( pVariantNameString );
tchar_t shaderTypeCharacter = pVariantNameString[ 0 ];
HELIUM_ASSERT( shaderTypeCharacter != TXT( '\0' ) );
RShader::EType shaderType;
switch( shaderTypeCharacter )
{
case TXT( 'v' ):
{
shaderType = RShader::TYPE_VERTEX;
break;
}
case TXT( 'p' ):
{
shaderType = RShader::TYPE_PIXEL;
break;
}
default:
{
HELIUM_TRACE(
TRACE_ERROR,
( TXT( "ShaderVariantResourceHandler: Failed to determine shader type from the name of object " )
TXT( "\"%s\".\n" ) ),
*pVariant->GetPath().ToString() );
return false;
}
}
uint32_t userOptionIndex = 0;
++pVariantNameString;
int parseResult;
#if HELIUM_UNICODE
#if HELIUM_CC_CL
parseResult = swscanf_s( pVariantNameString, TXT( "%" ) TSCNu32, &userOptionIndex );
#else
parseResult = swscanf( pVariantNameString, TXT( "%" ) TSCNu32, &userOptionIndex );
#endif
#else
#if HELIUM_CC_CL
parseResult = sscanf_s( pVariantNameString, TXT( "%" ) TSCNu32, &userOptionIndex );
#else
parseResult = sscanf( pVariantNameString, TXT( "%" ) TSCNu32, &userOptionIndex );
#endif
#endif
if( parseResult != 1 )
{
HELIUM_TRACE(
TRACE_ERROR,
( TXT( "ShaderVariantResourceHandler: Failed to parse user shader option set index from the name of " )
TXT( "option \"%s\".\n" ) ),
*pVariant->GetPath().ToString() );
return false;
}
// Get the parent shader.
Shader* pShader = Reflect::AssertCast< Shader >( pVariant->GetOwner() );
HELIUM_ASSERT( pShader );
HELIUM_ASSERT( pShader->GetAnyFlagSet( GameObject::FLAG_PRECACHED ) );
// Acquire the user preprocessor option set associated with the target shader type and user option set index.
const Shader::Options& rUserOptions = pShader->GetUserOptions();
DynArray< Name > toggleNames;
DynArray< Shader::SelectPair > selectPairs;
rUserOptions.GetOptionSetFromIndex( shaderType, userOptionIndex, toggleNames, selectPairs );
DynArray< PlatformPreprocessor::ShaderToken > shaderTokens;
size_t userToggleNameCount = toggleNames.GetSize();
for( size_t toggleNameIndex = 0; toggleNameIndex < userToggleNameCount; ++toggleNameIndex )
{
PlatformPreprocessor::ShaderToken* pToken = shaderTokens.New();
HELIUM_ASSERT( pToken );
StringConverter< tchar_t, char >::Convert( pToken->name, *toggleNames[ toggleNameIndex ] );
pToken->definition = "1";
}
size_t userSelectPairCount = selectPairs.GetSize();
for( size_t selectPairIndex = 0; selectPairIndex < userSelectPairCount; ++selectPairIndex )
{
const Shader::SelectPair& rPair = selectPairs[ selectPairIndex ];
//.........这里部分代码省略.........