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


C++ AssetPtr::Release方法代码示例

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


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

示例1: Initialize


//.........这里部分代码省略.........
	Shader* pShader = Reflect::SafeCast< Shader >( spShader.Get() );
	if ( HELIUM_VERIFY( pShader ) )
	{
		size_t loadId = pShader->BeginLoadVariant( RShader::TYPE_VERTEX, 0 );
		HELIUM_ASSERT( IsValid( loadId ) );
		if ( IsValid( loadId ) )
		{
			while ( !pShader->TryFinishLoadVariant( loadId, m_spSimpleWorldSpaceVertexShader ) )
			{
				pAssetLoader->Tick();
			}
		}

		loadId = pShader->BeginLoadVariant( RShader::TYPE_PIXEL, 0 );
		HELIUM_ASSERT( IsValid( loadId ) );
		if ( IsValid( loadId ) )
		{
			while ( !pShader->TryFinishLoadVariant( loadId, m_spSimpleWorldSpacePixelShader ) )
			{
				pAssetLoader->Tick();
			}
		}
	}

	HELIUM_VERIFY( shaderPath.Set( HELIUM_PACKAGE_PATH_CHAR_STRING "Shaders" HELIUM_OBJECT_PATH_CHAR_STRING "ScreenSpaceTexture.hlsl" ) );
	HELIUM_VERIFY( pAssetLoader->LoadObject( shaderPath, spShader ) );
	pShader = Reflect::SafeCast< Shader >( spShader.Get() );
	if ( HELIUM_VERIFY( pShader ) )
	{
		size_t loadId = pShader->BeginLoadVariant( RShader::TYPE_VERTEX, 0 );
		HELIUM_ASSERT( IsValid( loadId ) );
		if ( IsValid( loadId ) )
		{
			while ( !pShader->TryFinishLoadVariant( loadId, m_spSimpleScreenSpaceVertexShader ) )
			{
				pAssetLoader->Tick();
			}
		}

		loadId = pShader->BeginLoadVariant( RShader::TYPE_PIXEL, 0 );
		HELIUM_ASSERT( IsValid( loadId ) );
		if ( IsValid( loadId ) )
		{
			while ( !pShader->TryFinishLoadVariant( loadId, m_spSimpleScreenSpacePixelShader ) )
			{
				pAssetLoader->Tick();
			}
		}
	}

	HELIUM_VERIFY( shaderPath.Set( HELIUM_PACKAGE_PATH_CHAR_STRING "Shaders" HELIUM_OBJECT_PATH_CHAR_STRING "ScreenText.hlsl" ) );
	HELIUM_VERIFY( pAssetLoader->LoadObject( shaderPath, spShader ) );
	pShader = Reflect::SafeCast< Shader >( spShader.Get() );
	if ( HELIUM_VERIFY( pShader ) )
	{
		size_t loadId = pShader->BeginLoadVariant( RShader::TYPE_VERTEX, 0 );
		HELIUM_ASSERT( IsValid( loadId ) );
		if ( IsValid( loadId ) )
		{
			while ( !pShader->TryFinishLoadVariant( loadId, m_spScreenTextVertexShader ) )
			{
				pAssetLoader->Tick();
			}
		}

		loadId = pShader->BeginLoadVariant( RShader::TYPE_PIXEL, 0 );
		HELIUM_ASSERT( IsValid( loadId ) );
		if ( IsValid( loadId ) )
		{
			while ( !pShader->TryFinishLoadVariant( loadId, m_spScreenTextPixelShader ) )
			{
				pAssetLoader->Tick();
			}
		}
	}

	// Attempt to load the debug fonts.
	// TODO: XXX TMC: Migrate to a more data-driven solution.
	AssetPath fontPath;
	AssetPtr spFont;

	HELIUM_VERIFY( fontPath.Set( HELIUM_PACKAGE_PATH_CHAR_STRING "Fonts" HELIUM_OBJECT_PATH_CHAR_STRING "DebugSmall" ) );
	HELIUM_VERIFY( pAssetLoader->LoadObject( fontPath, spFont ) );
	m_debugFonts[DEBUG_FONT_SIZE_SMALL] = Reflect::SafeCast< Font >( spFont.Get() );
	spFont.Release();

	HELIUM_VERIFY( fontPath.Set( HELIUM_PACKAGE_PATH_CHAR_STRING "Fonts" HELIUM_OBJECT_PATH_CHAR_STRING "DebugMedium" ) );
	HELIUM_VERIFY( pAssetLoader->LoadObject( fontPath, spFont ) );
	m_debugFonts[DEBUG_FONT_SIZE_MEDIUM] = Reflect::SafeCast< Font >( spFont.Get() );
	spFont.Release();

	HELIUM_VERIFY( fontPath.Set( HELIUM_PACKAGE_PATH_CHAR_STRING "Fonts" HELIUM_OBJECT_PATH_CHAR_STRING "DebugLarge" ) );
	HELIUM_VERIFY( pAssetLoader->LoadObject( fontPath, spFont ) );
	m_debugFonts[DEBUG_FONT_SIZE_LARGE] = Reflect::SafeCast< Font >( spFont.Get() );
	spFont.Release();

#endif

	return true;
}
开发者ID:HeliumProject,项目名称:Helium,代码行数:101,代码来源:RenderResourceManager.cpp

示例2: CreateObject

/// Create a new object.
///
/// @param[out] rspObject             Pointer to the newly created object if object creation was successful.  Note that
///                                   any object reference stored in this strong pointer prior to calling this function
///                                   will always be cleared by this function, regardless of whether object creation is
///                                   successful.
/// @param[in]  pType                 Type of object to create.
/// @param[in]  name                  Object name.
/// @param[in]  pOwner                Object owner.
/// @param[in]  pTemplate             Optional override template object.  If null, the default template for the
///                                   specified type will be used.
/// @param[in]  bAssignInstanceIndex  True to assign an instance index to the object, false to leave the index
///                                   invalid.
///
/// @return  True if object creation was successful, false if not.
///
/// @see Create()
bool Asset::CreateObject(
	AssetPtr& rspObject,
	const AssetType* pType,
	Name name,
	Asset* pOwner,
	Asset* pTemplate,
	bool bAssignInstanceIndex )
{
	HELIUM_ASSERT( pType );

	HELIUM_TRACE(
		TraceLevels::Debug,
		TXT( "Asset::CreateObject(): Creating object named \"%s\" of type \"%s\" owned by \"%s\".\n"),
		*name,
		*pType->GetName(),
		!pOwner ? TXT("[none]") : *pOwner->GetPath().ToString());

	rspObject.Release();

	// Get the appropriate template object.
	Asset* pObjectTemplate = pTemplate;
	if( pObjectTemplate )
	{
		if( pType->GetFlags() & AssetType::FLAG_NO_TEMPLATE && pType->GetTemplate() != pObjectTemplate )
		{
			HELIUM_TRACE(
				TraceLevels::Error,
				TXT( "Asset::CreateObject(): Objects of type \"%s\" cannot be used as templates.\n" ),
				*pType->GetName() );

			return false;
		}
	}
	else
	{
		pObjectTemplate = pType->GetTemplate();
		HELIUM_ASSERT( pObjectTemplate );
	}

	// Make sure the object template is of the correct type.
	if( !pObjectTemplate->IsInstanceOf( pType ) )
	{
		HELIUM_TRACE(
			TraceLevels::Error,
			TXT( "Asset::CreateObject: Template object \"%s\" is not of type \"%s\".\n" ),
			*pTemplate->GetPath().ToString(),
			pType->GetName().Get() );
		HELIUM_BREAK();

		return false;
	}

	// Allocate memory for and create the object.
	DefaultAllocator allocator;

	size_t bufferSize = pObjectTemplate->GetInstanceSize();
	void* pObjectMemory = allocator.AllocateAligned( HELIUM_SIMD_ALIGNMENT, bufferSize );
	HELIUM_ASSERT( pObjectMemory );
	Asset* pObject = pObjectTemplate->InPlaceConstruct( pObjectMemory, StandardCustomDestroy );
	HELIUM_ASSERT( pObject == pObjectMemory );
	rspObject = pObject;

	// Initialize the object based on its default.
	pObjectTemplate->CopyTo(pObject);
	
	pObject->m_spTemplate = pTemplate;

	// Attempt to register the object and set its name.
	RenameParameters nameParameters;
	nameParameters.name = name;
	nameParameters.spOwner = pOwner;
	if( bAssignInstanceIndex )
	{
		nameParameters.instanceIndex = INSTANCE_INDEX_AUTO;
	}

	if ( !RegisterObject( pObject ) )
	{            
		HELIUM_TRACE(
			TraceLevels::Error,
			TXT( "Asset::CreateObject(): RegisterObject() failed for Asset \"%s\" owned by \"%s\".\n" ),
			*name,
			!pOwner ? TXT("[none]") : *pOwner->GetPath().ToString());
//.........这里部分代码省略.........
开发者ID:Fantasticer,项目名称:Helium,代码行数:101,代码来源:Asset.cpp


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