当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicArray::New方法代码示例

本文整理汇总了C++中DynamicArray::New方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::New方法的具体用法?C++ DynamicArray::New怎么用?C++ DynamicArray::New使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DynamicArray的用法示例。


在下文中一共展示了DynamicArray::New方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PrintArrayInfo

TEST(DataStructures, DynamicArray)
{
    {
        DynamicArray< int > intArray;
        intArray.Reserve( 3 );
        intArray.Add( 4 );
        //intArray.Add( 2 );
        HELIUM_VERIFY( intArray.New( 2 ) );
        intArray.Add( 8 );
        intArray.Add( 9 );
        intArray.Trim();

        PrintArrayInfo( TXT( "intArray" ), intArray );
    }

    {
        DynamicArray< NonTrivialClass > objectArray;
        objectArray.Reserve( 3 );
        objectArray.Add( NonTrivialClass( 4.3f ) );
        objectArray.Add( NonTrivialClass( 12.4f ) );
        objectArray.Add( NonTrivialClass( -3.9f ) );
        objectArray.Add( NonTrivialClass( 0.5f ) );
        objectArray.Add( NonTrivialClass( 2.9f ) );
        objectArray.Add( NonTrivialClass( -15.8f ) );
        objectArray.RemoveSwap( 1, 2 );
        objectArray.Trim();

        PrintArrayInfo( TXT( "objectArray" ), objectArray );
    }
}
开发者ID:KETMGaming,项目名称:Helium,代码行数:30,代码来源:GTest_Misc.cpp

示例2: Initialize

/// @copydoc CommandLineInitializer::Initialize()
bool CommandLineInitializationWin::Initialize( String& rModuleName, DynamicArray< String >& rArguments )
{
    rModuleName.Clear();
    rArguments.Clear();

    // Get the module file name and full command-line string (must use the wide-character versions, as there is only
    // a CommandLineToArgvW() and not a CommandLineToArgvA() to parse the command-line string).
    LPWSTR pCommandLine = GetCommandLineW();
    HELIUM_ASSERT( pCommandLine );
    if( !pCommandLine )
    {
        HELIUM_TRACE(
            TraceLevels::Error,
            TXT( "CommandLineInitializationWin::Initialize(): Failed to retrieve command-line string.\n" ) );

        return false;
    }

    WCHAR moduleFileName[ MAX_PATH ];
    DWORD moduleFileNameLength = GetModuleFileNameW( NULL, moduleFileName, MAX_PATH );
    if( moduleFileNameLength == 0 )
    {
        HELIUM_TRACE(
            TraceLevels::Error,
            TXT( "CommandLineInitializationWin::Initialize(): Failed to retrieve module file name string.\n" ) );

        return false;
    }

    moduleFileName[ MAX_PATH - 1 ] = L'\0';
    moduleFileNameLength = Min< DWORD >( moduleFileNameLength, MAX_PATH - 1 );

    // If the command line contains just the module file name, don't parse it and simply store the module name
    // (if no command-line arguments are specified, GetCommandLine() may return a string containing just the module
    // name without quoting it, which would in turn cause CommandLineToArgvW() to split the module path if it
    // contains any spaces).
    if( CompareString( pCommandLine, moduleFileName ) == 0 )
    {
        StringConverter< wchar_t, tchar_t >::Convert( rModuleName, moduleFileName );

        return true;
    }

    // Parse the command-line string.
    int argumentCount = 0;
    LPWSTR* ppArguments = CommandLineToArgvW( pCommandLine, &argumentCount );
    HELIUM_ASSERT( ppArguments );
    if( !ppArguments )
    {
        HELIUM_TRACE(
            TraceLevels::Error,
            TXT( "CommandLineInitializationWin::Initialize(): Failed to parse command-line arguments.\n" ) );

        return false;
    }

    StringConverter< wchar_t, tchar_t >::Convert( rModuleName, moduleFileName );

    if( argumentCount > 1 )
    {
        rArguments.Reserve( argumentCount - 1 );

        for( int argumentIndex = 1; argumentIndex < argumentCount; ++argumentIndex )
        {
            LPWSTR pArgument = ppArguments[ argumentIndex ];
            HELIUM_ASSERT( pArgument );
            String* pConvertedArgument = rArguments.New();
            HELIUM_ASSERT( pConvertedArgument );
            StringConverter< wchar_t, tchar_t >::Convert( *pConvertedArgument, pArgument );
        }
    }

    LocalFree( ppArguments );

    return true;
}
开发者ID:foolhuang,项目名称:Helium,代码行数:77,代码来源:CommandLineInitializerWin.cpp

示例3: _tWinMain


//.........这里部分代码省略.........

#if MULTI_WINDOW
	spSubRenderContext.Release();
#endif
	spMainRenderContext.Release();

	
	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);
开发者ID:kevindqc,项目名称:Helium,代码行数:67,代码来源:TestApp.cpp

示例4: SynchronizeShaderParameters


//.........这里部分代码省略.........
                    {
                        for( parameterIndex = 0; parameterIndex < existingFloat3Count; ++parameterIndex )
                        {
                            const Float3Parameter& rExistingParameter = m_float3Parameters[ parameterIndex ];
                            if( rExistingParameter.name == constantName )
                            {
                                newValue.SetElement( 0, rExistingParameter.value.GetElement( 0 ) );
                                newValue.SetElement( 1, rExistingParameter.value.GetElement( 1 ) );
                                newValue.SetElement( 2, rExistingParameter.value.GetElement( 2 ) );

                                break;
                            }
                        }

                        if( parameterIndex >= existingFloat3Count )
                        {
                            for( parameterIndex = 0; parameterIndex < existingFloat4Count; ++parameterIndex )
                            {
                                const Float4Parameter& rExistingParameter =
                                    m_float4Parameters[ parameterIndex ];
                                if( rExistingParameter.name == constantName )
                                {
                                    newValue = rExistingParameter.value;

                                    break;
                                }
                            }
                        }
                    }
                }

                if( constantSize < sizeof( float32_t ) * 2 )
                {
                    Float1Parameter* pParameter = newFloat1Parameters.New();
                    HELIUM_ASSERT( pParameter );
                    pParameter->name = constantName;
                    pParameter->value = newValue.GetElement( 0 );
                }
                else if( constantSize < sizeof( float32_t ) * 3 )
                {
                    Float2Parameter* pParameter = newFloat2Parameters.New();
                    HELIUM_ASSERT( pParameter );
                    pParameter->name = constantName;
                    pParameter->value = Simd::Vector2( newValue.GetElement( 0 ), newValue.GetElement( 1 ) );
                }
                else if( constantSize < sizeof( float32_t ) * 4 )
                {
                    Float3Parameter* pParameter = newFloat3Parameters.New();
                    HELIUM_ASSERT( pParameter );
                    pParameter->name = constantName;
                    pParameter->value =
                        Simd::Vector3( newValue.GetElement( 0 ), newValue.GetElement( 1 ), newValue.GetElement( 2 ) );
                }
                else
                {
                    Float4Parameter* pParameter = newFloat4Parameters.New();
                    HELIUM_ASSERT( pParameter );
                    pParameter->name = constantName;
                    pParameter->value = newValue;
                }
            }
        }
    }

    newFloat1Parameters.Trim();
    newFloat2Parameters.Trim();
开发者ID:foolhuang,项目名称:Helium,代码行数:67,代码来源:Material.cpp

示例5: CompressTexture

/// Compress a font texture sheet and add the texture data to the given texture sheet array.
///
/// @param[in] pGrayscaleData  Texture sheet data, stored as a contiguous array of 8-bit grayscale values.
/// @param[in] textureWidth    Width of the texture sheet.
/// @param[in] textureHeight   Height of the texture sheet.
/// @param[in] compression     Font texture sheet compression method to use.
/// @param[in] rTextureSheets  Array of texture sheets to which the texture data should be appended.
void FontResourceHandler::CompressTexture(
    const uint8_t* pGrayscaleData,
    uint16_t textureWidth,
    uint16_t textureHeight,
    Font::ECompression compression,
    DynamicArray< DynamicArray< uint8_t > >& rTextureSheets )
{
    HELIUM_ASSERT( pGrayscaleData );

    DynamicArray< uint8_t >* pOutputSheet = rTextureSheets.New();
    HELIUM_ASSERT( pOutputSheet );

    // If the output is to be uncompressed grayscale data, simply copy the data to the output texture, as it's already
    // uncompressed grayscale data.
    if( compression == Font::ECompression::GRAYSCALE_UNCOMPRESSED )
    {
        size_t pixelCount = static_cast< size_t >( textureWidth ) * static_cast< size_t >( textureHeight );
        pOutputSheet->AddArray( pGrayscaleData, pixelCount );

        return;
    }

    // Convert the source image to a 32-bit BGRA image for the NVIDIA texture tools library to process.
    Image::InitParameters imageParameters;
    imageParameters.format.SetBytesPerPixel( 4 );
    imageParameters.format.SetChannelBitCount( Image::CHANNEL_RED, 8 );
    imageParameters.format.SetChannelBitCount( Image::CHANNEL_GREEN, 8 );
    imageParameters.format.SetChannelBitCount( Image::CHANNEL_BLUE, 8 );
    imageParameters.format.SetChannelBitCount( Image::CHANNEL_ALPHA, 8 );
#if HELIUM_ENDIAN_LITTLE
    imageParameters.format.SetChannelBitOffset( Image::CHANNEL_RED, 16 );
    imageParameters.format.SetChannelBitOffset( Image::CHANNEL_GREEN, 8 );
    imageParameters.format.SetChannelBitOffset( Image::CHANNEL_BLUE, 0 );
    imageParameters.format.SetChannelBitOffset( Image::CHANNEL_ALPHA, 24 );
#else
    imageParameters.format.SetChannelBitOffset( Image::CHANNEL_RED, 8 );
    imageParameters.format.SetChannelBitOffset( Image::CHANNEL_GREEN, 16 );
    imageParameters.format.SetChannelBitOffset( Image::CHANNEL_BLUE, 24 );
    imageParameters.format.SetChannelBitOffset( Image::CHANNEL_ALPHA, 0 );
#endif
    imageParameters.width = textureWidth;
    imageParameters.height = textureHeight;

    Image bgraImage;
    HELIUM_VERIFY( bgraImage.Initialize( imageParameters ) );

    uint_fast32_t imageWidth = textureWidth;
    uint_fast32_t imageHeight = textureHeight;
    uint_fast32_t imagePitch = bgraImage.GetPitch();

    uint8_t* pImagePixelData = static_cast< uint8_t* >( bgraImage.GetPixelData() );
    HELIUM_ASSERT( pImagePixelData );
    uint8_t* pImageRow = pImagePixelData;

    for( uint_fast32_t imageY = 0; imageY < imageHeight; ++imageY )
    {
        uint8_t* pOutputPixel = pImageRow;

        for( uint_fast32_t imageX = 0; imageX < imageWidth; ++imageX )
        {
            uint8_t pixel = *( pGrayscaleData++ );

            *( pOutputPixel++ ) = pixel;
            *( pOutputPixel++ ) = pixel;
            *( pOutputPixel++ ) = pixel;
            *( pOutputPixel++ ) = 0xff;
        }

        pImageRow += imagePitch;
    }

    // Set up the input options for the texture compressor.
    nvtt::InputOptions inputOptions;
    inputOptions.setTextureLayout( nvtt::TextureType_2D, textureWidth, textureHeight );
    inputOptions.setMipmapData( pImagePixelData, textureWidth, textureHeight );
    inputOptions.setMipmapGeneration( false );
    inputOptions.setWrapMode( nvtt::WrapMode_Repeat );
    inputOptions.setGamma( 1.0f, 1.0f );
    inputOptions.setNormalMap( false );

    // Set up the output options for the texture compressor.
    MemoryTextureOutputHandler outputHandler( textureWidth, textureHeight, false, false );

    nvtt::OutputOptions outputOptions;
    outputOptions.setOutputHandler( &outputHandler );
    outputOptions.setOutputHeader( false );

    // Set up the compression options for the texture compressor (note that the only compression option we currently
    // support other than uncompressed grayscale is BC1/DXT1).
    nvtt::CompressionOptions compressionOptions;
    compressionOptions.setFormat( nvtt::Format_BC1 );
    compressionOptions.setQuality( nvtt::Quality_Normal );

//.........这里部分代码省略.........
开发者ID:HeliumProject,项目名称:Helium,代码行数:101,代码来源:FontResourceHandler.cpp

示例6: TryFinishLoadObject

/// @copydoc PackageLoader::TryFinishLoadObject()
bool CachePackageLoader::TryFinishLoadObject(
    size_t requestId,
    GameObjectPtr& rspObject,
    DynamicArray< GameObjectLoader::LinkEntry >& rLinkTable )
{
    HELIUM_ASSERT( requestId < m_loadRequests.GetSize() );
    HELIUM_ASSERT( m_loadRequests.IsElementValid( requestId ) );

    LoadRequest* pRequest = m_loadRequests[ requestId ];
    HELIUM_ASSERT( pRequest );
    if( !( pRequest->flags & LOAD_FLAG_PRELOADED ) )
    {
        return false;
    }

    // Sync on template and owner dependencies.
    GameObjectLoader* pObjectLoader = GameObjectLoader::GetStaticInstance();
    HELIUM_ASSERT( pObjectLoader );

    DynamicArray< size_t >& rInternalLinkTable = pRequest->objectLinkTable;

    if( IsValid( pRequest->templateLinkIndex ) )
    {
        size_t linkLoadId = rInternalLinkTable[ pRequest->templateLinkIndex ];
        if( IsValid( linkLoadId ) && !pObjectLoader->TryFinishLoad( linkLoadId, pRequest->spTemplate ) )
        {
            return false;
        }

        SetInvalid( pRequest->templateLinkIndex );
    }

    if( IsValid( pRequest->ownerLinkIndex ) )
    {
        size_t linkLoadId = rInternalLinkTable[ pRequest->ownerLinkIndex ];
        if( IsValid( linkLoadId ) && !pObjectLoader->TryFinishLoad( linkLoadId, pRequest->spOwner ) )
        {
            return false;
        }

        SetInvalid( pRequest->ownerLinkIndex );
    }

    rspObject = pRequest->spObject;
    GameObject* pObject = rspObject;
    if( pObject && ( pRequest->flags & LOAD_FLAG_ERROR ) )
    {
        pObject->SetFlags( GameObject::FLAG_BROKEN );
    }

    pRequest->spObject.Release();

    size_t linkTableSize = rInternalLinkTable.GetSize();
    rLinkTable.Resize( 0 );
    rLinkTable.Reserve( linkTableSize );
    for( size_t linkIndex = 0; linkIndex < linkTableSize; ++linkIndex )
    {
        GameObjectLoader::LinkEntry* pEntry = rLinkTable.New();
        HELIUM_ASSERT( pEntry );
        pEntry->loadId = rInternalLinkTable[ linkIndex ];
        pEntry->spObject.Release();
    }

    rInternalLinkTable.Resize( 0 );

    HELIUM_ASSERT( IsInvalid( pRequest->asyncLoadId ) );
    HELIUM_ASSERT( !pRequest->pAsyncLoadBuffer );

    pRequest->spType.Release();
    pRequest->spTemplate.Release();
    pRequest->spOwner.Release();
    pRequest->typeLinkTable.Resize( 0 );

    HELIUM_ASSERT( pObject || pRequest->pEntry );
    HELIUM_TRACE(
        TraceLevels::Debug,
        ( TXT( "CachePackageLoader::TryFinishLoadObject(): Load request for \"%s\" (ID: %" ) TPRIuSZ TXT( ") " )
        TXT( "synced.\n" ) ),
        *( pObject ? pObject->GetPath() : pRequest->pEntry->path ).ToString(),
        requestId );

    m_loadRequests.Remove( requestId );
    m_loadRequestPool.Release( pRequest );

    return true;
}
开发者ID:foolhuang,项目名称:Helium,代码行数:87,代码来源:CachePackageLoader.cpp

示例7: ReplaceAsset

void Asset::ReplaceAsset( Asset* pNewAsset, const AssetPath &objectToReplace )
{
	AssetAwareThreadSynchronizer::Lock assetLock;

	// Acquire a write lock on the object list to prevent objects from being added and removed as well as keep
	// objects from being renamed while this object is being renamed.
	ScopeWriteLock scopeLock( sm_objectListLock );

	Asset *pOldAsset = Asset::FindObject( objectToReplace );
	HELIUM_ASSERT( pNewAsset->GetMetaClass()->IsType( pOldAsset->GetMetaClass() ) );

	DynamicArray<AssetFixup> fixups;

	// For every asset in existence
	for ( SparseArray< AssetWPtr >::Iterator iter = sm_objects.Begin();
		iter != sm_objects.End(); ++iter)
	{
		if ( !iter )
		{
			continue;
		}

		Asset* pPossibleFixupAsset = iter->Get();
		if ( !pPossibleFixupAsset || pPossibleFixupAsset->IsDefaultTemplate() )
		{
			continue;
		}

		// Ignore it if it's the asset we're swapping
		if ( pPossibleFixupAsset->m_id == pNewAsset->m_id || pPossibleFixupAsset->m_id == pOldAsset->m_id )
		{
			continue;
		}
		
		// If the asset has the old asset as a template (direct or indirect)
		Asset *pTemplate = pPossibleFixupAsset->GetTemplateAsset().Get();
		
		while ( pTemplate && !pTemplate->IsDefaultTemplate() )
		{
			if ( pTemplate == pOldAsset )
			{
				// Then save it off
				// TODO: Does order matter? Right now we probably want bases first so that changes ripple down the template
				// tree but in future we should probably have a flag of some sort to say if a field is set or not. Maybe in tools only.
				AssetFixup &fixup = *fixups.New();
				fixup.pAsset = pPossibleFixupAsset;
				break;
			}

			pTemplate = pTemplate->GetTemplateAsset().Get();
		}
	}

	const Reflect::MetaStruct *pStruct = pOldAsset->GetMetaClass();

	// Get all the bases
	// TODO: Declare a max depth for inheritance to save heap allocs -geoff
	DynamicArray< const Reflect::MetaStruct* > bases;
	for ( const Reflect::MetaStruct* current = pStruct; current != NULL; current = current->m_Base )
	{
		bases.Push( current );
	}

	// For all assets that depend on the changing asset
	for ( DynamicArray<AssetFixup>::Iterator iter = fixups.Begin();
		iter != fixups.End(); ++iter)
	{
		// Get the template (old) asset's type
		Asset *pAsset = iter->pAsset;

		// Get all the fields that should be modified due to the base template changing
		// TODO: Declare a max count for fields to save heap allocs -geoff
		DynamicArray< const Reflect::Field* > fields;
		while ( !bases.IsEmpty() )
		{
			const Reflect::MetaStruct* current = bases.Pop();
			DynamicArray< Reflect::Field >::ConstIterator itr = current->m_Fields.Begin();
			DynamicArray< Reflect::Field >::ConstIterator end = current->m_Fields.End();
			for ( ; itr != end; ++itr )
			{
				// Field is guaranteed to be in all objects of the template dependency chain
				const Reflect::Field* field = &*itr;

				// For every field
				for ( uint32_t i = 0; i < field->m_Count; ++i )
				{
					bool isOverridden = false;
					Reflect::Pointer assetPointer( field, pAsset, i );

					// Is there anywhere in the template chain that the field gets overridden?
					Asset *pTemplate = pAsset->GetTemplateAsset();
					while ( pTemplate )
					{
						Reflect::Pointer templatePointer( field, pTemplate, i );

						if ( !field->m_Translator->Equals( assetPointer, templatePointer ) )
						{
							// Yes, bail
							isOverridden = true;
							break;
//.........这里部分代码省略.........
开发者ID:Fantasticer,项目名称:Helium,代码行数:101,代码来源:Asset.cpp

示例8: CacheResource

/// @copydoc ResourceHandler::CacheResource()
bool FontResourceHandler::CacheResource(
    ObjectPreprocessor* pObjectPreprocessor,
    Resource* pResource,
    const String& rSourceFilePath )
{
    HELIUM_ASSERT( pObjectPreprocessor );
    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,
            TXT( "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,
            ( TXT( "FontResourceHandler: Font file \"%s\" exceeds the maximum addressable size of data in memory for " )
              TXT( "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,
            ( TXT( "FontResourceHandler: Failed to allocate %" ) TPRIuSZ TXT( " bytes for resource data for font " )
              TXT( "\"%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,
            ( TXT( "FontResourceHandler: Attempted to read %" ) TPRIuSZ TXT( " bytes from font resource file \"%s\", " )
              TXT( "but only %" ) TPRIuSZ TXT( " 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,
            TXT( "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,
            TXT( "FontResourceHandler: Failed to set size of font resource \"%s\".\n" ),
            *rSourceFilePath );

        FT_Done_Face( pFace );
        delete [] pFileData;
//.........这里部分代码省略.........
开发者ID:foolhuang,项目名称:Helium,代码行数:101,代码来源:FontResourceHandler.cpp


注:本文中的DynamicArray::New方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。