本文整理汇总了C++中DynamicArray::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::GetSize方法的具体用法?C++ DynamicArray::GetSize怎么用?C++ DynamicArray::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicArray
的用法示例。
在下文中一共展示了DynamicArray::GetSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadCacheObjectFromBuffer
Reflect::ObjectPtr Helium::Cache::ReadCacheObjectFromBuffer( const DynamicArray< uint8_t > &_buffer )
{
if (_buffer.GetSize() == 0)
{
Reflect::ObjectPtr null_object;
return null_object;
}
return ReadCacheObjectFromBuffer(_buffer.GetData(), 0, _buffer.GetSize());
}
示例2: ParseLineDuplicateOptionCheck
bool ShaderResourceHandler::ParseLineDuplicateOptionCheck( Name optionName, const DynamicArray< OptionType >& rOptions )
{
size_t optionCount = rOptions.GetSize();
for( size_t optionIndex = 0; optionIndex < optionCount; ++optionIndex )
{
if( rOptions[ optionIndex ].name == optionName )
{
return true;
}
}
return false;
}
示例3: enabledChoice
void Helium::Material::PreSerialize( const Reflect::Field* field )
{
m_userOptions.Resize(0);
Shader* pShader = m_spShader;
if( pShader )
{
const Shader::Options& rUserOptions = pShader->GetUserOptions();
DynamicArray< Name > enabledToggles;
rUserOptions.GetOptionSetFromIndex(
RShader::TYPE_FIRST,
m_persistentResourceData.m_shaderVariantIndices[ 0 ],
enabledToggles,
m_userOptions );
size_t enabledToggleCount = enabledToggles.GetSize();
Shader::SelectPair optionPair;
Name enabledChoice( TXT( "1" ) );
Name disabledChoice( TXT( "0" ) );
const DynamicArray< Shader::Toggle >& rUserToggles = rUserOptions.GetToggles();
size_t userToggleCount = rUserToggles.GetSize();
for( size_t userToggleIndex = 0; userToggleIndex < userToggleCount; ++userToggleIndex )
{
optionPair.name = rUserToggles[ userToggleIndex ].name;
size_t enabledToggleIndex;
for( enabledToggleIndex = 0; enabledToggleIndex < enabledToggleCount; ++enabledToggleIndex )
{
if( enabledToggles[ enabledToggleIndex ] == optionPair.name )
{
break;
}
}
optionPair.choice =
( enabledToggleIndex < enabledToggleCount ? enabledChoice : disabledChoice );
m_userOptions.Push( optionPair );
}
}
}
示例4: ParseLine
/// Parse the given shader source line for toggle and select options.
///
/// @param[in] shaderPath GameObject path of the shader resource being preprocessed (used for logging purposes
/// only).
/// @param[in] rResourceData Persistent shader resource data to update.
/// @param[in] pLineStart Pointer to the first character in the line.
/// @param[in] pLineEnd Pointer to the character just past the end of the line.
void ShaderResourceHandler::ParseLine(
GameObjectPath shaderPath,
Shader::PersistentResourceData& rResourceData,
const char* pLineStart,
const char* pLineEnd )
{
HELIUM_UNREF( shaderPath ); // Not used if logging is disabled.
HELIUM_ASSERT( pLineStart );
HELIUM_ASSERT( pLineEnd >= pLineStart );
const char linePrefix[] = "//!";
const char toggleUserCommand[] = "@toggle";
const char selectUserCommand[] = "@select";
const char toggleSystemCommand[] = "@systoggle";
const char selectSystemCommand[] = "@sysselect";
size_t characterCount = static_cast< size_t >( pLineEnd - pLineStart );
// Only process lines that start with the special comment prefix.
if( characterCount < HELIUM_ARRAY_COUNT( linePrefix ) - 1 ||
CompareString( pLineStart, linePrefix, HELIUM_ARRAY_COUNT( linePrefix ) - 1 ) != 0 )
{
return;
}
pLineStart += HELIUM_ARRAY_COUNT( linePrefix ) - 1;
characterCount -= HELIUM_ARRAY_COUNT( linePrefix ) - 1;
// Split the line based on groups of whitespaces.
CharString line( pLineStart, characterCount );
DynamicArray< CharString > splitLine;
line.Split( splitLine, " \t\v\f", Invalid< size_t >(), true );
// Ignore the first split if it's empty (will occur if the command is preceded by whitespaces).
size_t splitCount = splitLine.GetSize();
if( splitCount > 0 && splitLine[ 0 ].IsEmpty() )
{
splitLine.Remove( 0 );
--splitCount;
}
// We need at least 2 splits (command and at least one command parameter).
if( splitCount < 2 )
{
return;
}
// Process the command.
DynamicArray< CharString > splitCommand;
splitLine[ 0 ].Split( splitCommand, '_' );
size_t commandSplitCount = splitCommand.GetSize();
if( commandSplitCount < 1 || commandSplitCount > 2 )
{
// Invalid command format.
return;
}
const CharString& rCommand = splitCommand[ 0 ];
bool bToggleUserCommand = ( rCommand == toggleUserCommand );
bool bSelectUserCommand = ( !bToggleUserCommand && rCommand == selectUserCommand );
bool bToggleSystemCommand = ( !( bToggleUserCommand | bSelectUserCommand ) && rCommand == toggleSystemCommand );
bool bSelectSystemCommand =
( !( bToggleUserCommand | bSelectUserCommand | bToggleSystemCommand ) && rCommand == selectSystemCommand );
if( !( bToggleUserCommand | bSelectUserCommand | bToggleSystemCommand | bSelectSystemCommand ) )
{
return;
}
/// Make sure the option name (first parameter after the command name) is valid.
String convertedString;
HELIUM_VERIFY( ( StringConverter< char, tchar_t >::Convert( convertedString, splitLine[ 1 ] ) ) );
Name optionName( convertedString );
if( optionName.IsEmpty() )
{
HELIUM_TRACE(
TraceLevels::Error,
TXT( "ShaderResourceHandler: Skipping empty option in shader resource \"%s\".\n" ),
*shaderPath.ToString() );
return;
}
// Make sure an existing toggle or selection option exists with the parsed option name.
Shader::Options& rSystemOptions = rResourceData.GetSystemOptions();
Shader::Options& rUserOptions = rResourceData.GetUserOptions();
DynamicArray< Shader::Toggle >& rSystemToggles = rSystemOptions.GetToggles();
DynamicArray< Shader::Select >& rSystemSelects = rSystemOptions.GetSelects();
DynamicArray< Shader::Toggle >& rUserToggles = rUserOptions.GetToggles();
//.........这里部分代码省略.........
示例5: _tWinMain
//.........这里部分代码省略.........
Helium::StrongPtr<Helium::Texture2d> texture;
gAssetLoader->LoadObject( AssetPath( TXT( "/Textures:Triangle.png" ) ), texture);
Helium::RTexture2d *rTexture2d = texture->GetRenderResource2d();
while( windowData.bProcessMessages )
{
#if GRAPHICS_SCENE_BUFFERED_DRAWER
BufferedDrawer& rSceneDrawer = pGraphicsScene->GetSceneBufferedDrawer();
rSceneDrawer.DrawScreenText(
20,
20,
String( TXT( "RUNNING" ) ),
Color( 0xffffffff ),
RenderResourceManager::DEBUG_FONT_SIZE_LARGE );
rSceneDrawer.DrawScreenText(
21,
20,
String( TXT( "RUNNING" ) ),
Color( 0xffffffff ),
RenderResourceManager::DEBUG_FONT_SIZE_LARGE );
time += 0.01f;
DynamicArray<SimpleVertex> verticesU;
verticesU.New( -100.0f, -100.0f, 750.0f );
verticesU.New( 100.0f, -100.0f, 750.0f );
verticesU.New( 100.0f, 100.0f, 750.0f );
verticesU.New( -100.0f, 100.0f, 750.0f );
rSceneDrawer.DrawLineList( verticesU.GetData(), static_cast<uint32_t>( verticesU.GetSize() ) );
DynamicArray<SimpleTexturedVertex> verticesT;
verticesT.New( Simd::Vector3( -100.0f, 100.0f, 750.0f ), Simd::Vector2( 0.0f, 0.0f ) );
verticesT.New( Simd::Vector3( 100.0f, 100.0f, 750.0f ), Simd::Vector2( 1.0f, 0.0f ) );
verticesT.New( Simd::Vector3( -100.0f, -100.0f, 750.0f ), Simd::Vector2( 0.0f, 1.0f ) );
verticesT.New( Simd::Vector3( 100.0f, -100.0f, 750.0f ), Simd::Vector2( 1.0f, 1.0f ) );
//rSceneDrawer.DrawTextured(
// RENDERER_PRIMITIVE_TYPE_TRIANGLE_STRIP,
// verticesT.GetData(),
// verticesT.GetSize(),
// NULL,
// 2,
// rTexture2d, Helium::Color(1.0f, 1.0f, 1.0f, 1.0f), Helium::RenderResourceManager::RASTERIZER_STATE_DEFAULT, Helium::RenderResourceManager::DEPTH_STENCIL_STATE_NONE);
//rSceneDrawer.DrawTexturedQuad(rTexture2d);
Helium::Simd::Matrix44 transform = Helium::Simd::Matrix44::IDENTITY;
Simd::Vector3 location(0.0f, 400.0f, 0.0f);
Simd::Quat rotation(Helium::Simd::Vector3::BasisZ, time);
Simd::Vector3 scale(1000.0f, 1000.0f, 1000.0f);
transform.SetRotationTranslationScaling(rotation, location, scale);
rSceneDrawer.DrawTexturedQuad(rTexture2d, transform, Simd::Vector2(0.0f, 0.0f), Simd::Vector2(0.5f, 0.5f));
#endif
//Helium::Simd::Vector3 up = Simd::Vector3::BasisY;
////Helium::Simd::Vector3 eye(5000.0f * sin(time), 0.0f, 5000.0f * cos(time));
示例6: SynchronizeShaderParameters
/// Synchronize the shader parameter list with those provided by the selected shader variant.
///
/// @see SynchronizeFloatVectorParameters(), SynchronizeTextureParameters()
void Material::SynchronizeShaderParameters()
{
Shader* pShader = m_spShader;
if( !pShader )
{
m_float1Parameters.Clear();
m_float2Parameters.Clear();
m_float3Parameters.Clear();
m_float4Parameters.Clear();
m_textureParameters.Clear();
}
// Synchronize floating-point constant parameters.
Name parameterConstantBufferName = GetParameterConstantBufferName();
size_t existingFloat1Count = m_float1Parameters.GetSize();
size_t existingFloat2Count = m_float2Parameters.GetSize();
size_t existingFloat3Count = m_float3Parameters.GetSize();
size_t existingFloat4Count = m_float4Parameters.GetSize();
DynamicArray< Float1Parameter > newFloat1Parameters;
DynamicArray< Float2Parameter > newFloat2Parameters;
DynamicArray< Float3Parameter > newFloat3Parameters;
DynamicArray< Float4Parameter > newFloat4Parameters;
for( size_t shaderTypeIndex = 0; shaderTypeIndex < HELIUM_ARRAY_COUNT( m_shaderVariants ); ++shaderTypeIndex )
{
ShaderVariant* pShaderVariant = m_shaderVariants[ shaderTypeIndex ];
if( !pShaderVariant )
{
continue;
}
const ShaderConstantBufferInfoSet* pBufferSet = pShaderVariant->GetConstantBufferInfoSet( 0 );
if( !pBufferSet )
{
continue;
}
bool bCheckDuplicates =
( !newFloat1Parameters.IsEmpty() || !newFloat2Parameters.IsEmpty() || !newFloat3Parameters.IsEmpty() ||
!newFloat4Parameters.IsEmpty() );
const DynamicArray< ShaderConstantBufferInfo >& rBuffers = pBufferSet->buffers;
size_t bufferCount = rBuffers.GetSize();
for( size_t bufferIndex = 0; bufferIndex < bufferCount; ++bufferIndex )
{
const ShaderConstantBufferInfo& rBufferInfo = rBuffers[ bufferIndex ];
if( rBufferInfo.name != parameterConstantBufferName )
{
continue;
}
const DynamicArray< ShaderConstantInfo >& rConstants = rBufferInfo.constants;
size_t constantCount = rConstants.GetSize();
for( size_t constantIndex = 0; constantIndex < constantCount; ++constantIndex )
{
const ShaderConstantInfo& rConstantInfo = rConstants[ constantIndex ];
// Constants must be between 1 and 4 floating-point values.
uint16_t constantSize = rConstantInfo.usedSize;
if( constantSize < sizeof( float32_t ) || constantSize > sizeof( float32_t ) * 4 )
{
continue;
}
Name constantName = rConstantInfo.name;
size_t parameterIndex;
if( bCheckDuplicates )
{
size_t parameterCount = newFloat1Parameters.GetSize();
for( parameterIndex = 0; parameterIndex < parameterCount; ++parameterIndex )
{
if( newFloat1Parameters[ parameterIndex ].name == constantName )
{
break;
}
}
if( parameterIndex < parameterCount )
{
continue;
}
parameterCount = newFloat2Parameters.GetSize();
for( parameterIndex = 0; parameterIndex < parameterCount; ++parameterIndex )
{
if( newFloat2Parameters[ parameterIndex ].name == constantName )
{
break;
}
}
if( parameterIndex < parameterCount )
{
continue;
}
//.........这里部分代码省略.........
示例7: CacheResource
/// @copydoc ResourceHandler::CacheResource()
bool FontResourceHandler::CacheResource(
AssetPreprocessor* pAssetPreprocessor,
Resource* pResource,
const String& rSourceFilePath )
{
HELIUM_ASSERT( pAssetPreprocessor );
HELIUM_ASSERT( pResource );
Font* pFont = Reflect::AssertCast< Font >( pResource );
// Load the font into memory ourselves in order to make sure we properly support Unicode file names.
FileStream* pFileStream = FileStream::OpenFileStream( rSourceFilePath, FileStream::MODE_READ );
if( !pFileStream )
{
HELIUM_TRACE(
TraceLevels::Error,
"FontResourceHandler: Source file for font resource \"%s\" failed to open properly.\n",
*rSourceFilePath );
return false;
}
uint64_t fileSize64 = static_cast< uint64_t >( pFileStream->GetSize() );
if( fileSize64 > SIZE_MAX )
{
HELIUM_TRACE(
TraceLevels::Error,
"FontResourceHandler: Font file \"%s\" exceeds the maximum addressable size of data in memory for this platform and will not be cached.\n",
*rSourceFilePath );
delete pFileStream;
return false;
}
size_t fileSize = static_cast< size_t >( fileSize64 );
uint8_t* pFileData = new uint8_t [ fileSize ];
if( !pFileData )
{
HELIUM_TRACE(
TraceLevels::Error,
"FontResourceHandler: Failed to allocate %" PRIuSZ " bytes for resource data for font \"%s\".\n",
fileSize,
*rSourceFilePath );
delete pFileStream;
return false;
}
size_t bytesRead = pFileStream->Read( pFileData, 1, fileSize );
delete pFileStream;
if( bytesRead != fileSize )
{
HELIUM_TRACE(
TraceLevels::Warning,
"FontResourceHandler: Attempted to read %" PRIuSZ " bytes from font resource file \"%s\", but only %" PRIuSZ " bytes were read successfully.\n",
fileSize,
*rSourceFilePath,
bytesRead );
}
// Create the font face.
FT_Library pLibrary = GetStaticLibrary();
HELIUM_ASSERT( pLibrary );
FT_Face pFace = NULL;
FT_Error error = FT_New_Memory_Face( pLibrary, pFileData, static_cast< FT_Long >( bytesRead ), 0, &pFace );
if( error != 0 )
{
HELIUM_TRACE(
TraceLevels::Error,
"FontResourceHandler: Failed to create font face from resource file \"%s\".\n",
*rSourceFilePath );
delete [] pFileData;
return false;
}
// Set the appropriate font size.
int32_t pointSize = Font::Float32ToFixed26x6( pFont->GetPointSize() );
uint32_t dpi = pFont->GetDpi();
error = FT_Set_Char_Size( pFace, pointSize, pointSize, dpi, dpi );
if( error != 0 )
{
HELIUM_TRACE(
TraceLevels::Error,
"FontResourceHandler: Failed to set size of font resource \"%s\".\n",
*rSourceFilePath );
FT_Done_Face( pFace );
delete [] pFileData;
return false;
}
//.........这里部分代码省略.........