本文整理汇总了C++中ITexture::AddRef方法的典型用法代码示例。如果您正苦于以下问题:C++ ITexture::AddRef方法的具体用法?C++ ITexture::AddRef怎么用?C++ ITexture::AddRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITexture
的用法示例。
在下文中一共展示了ITexture::AddRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChangeEntityDiffuseTextureForMaterial
void CCoherentUISystem::ChangeEntityDiffuseTextureForMaterial( CCoherentViewListener* pViewListener, const char* entityName, const char* materialName )
{
IMaterial* pMaterial = gEnv->p3DEngine->GetMaterialManager()->FindMaterial( materialName );
IEntity* pEntity = gEnv->pEntitySystem->FindEntityByName( entityName );
if ( pEntity && !pMaterial )
{
pMaterial = pEntity->GetMaterial();
}
if ( pMaterial )
{
STexSamplerRT& sampler = pMaterial->GetShaderItem().m_pShaderResources->GetTexture( EFTT_DIFFUSE )->m_Sampler;
// Create a new texture and scrap the old one
void* pD3DTextureDst = NULL;
ITexture* pCryTex = gD3DSystem->CreateTexture(
&pD3DTextureDst,
sampler.m_pITex->GetWidth(),
sampler.m_pITex->GetHeight(),
1,
eTF_A8R8G8B8,
FT_USAGE_DYNAMIC
);
int oldTextureID = sampler.m_pITex->GetTextureID();
gEnv->pRenderer->RemoveTexture( oldTextureID );
sampler.m_pITex = pCryTex;
pCryTex->AddRef();
pViewListener->SetTexture( pD3DTextureDst, pCryTex->GetTextureID() );
}
}
示例2: GetAssetById
/*
* Creates a render target
* Param _kfWidth : The width of the render terget
* Param _kfHeight : The height of th erender target
* Param _keFMT : The render targets format
* Return : ITexture, The render target
*/
ITexture* CDX9TextureManager::CreateRenderTarget( CAssetId& _rAssetId,const uint32 _kuWidth, const uint32 _kuHeight, const ESurfaceFormat _keFMT, const bool _bWriteOnly )
{
// Check if the render target has already been created.
ITexture* pRenderTarget = NULL;
pRenderTarget = GetAssetById( _rAssetId );
if( pRenderTarget )
{
pRenderTarget->AddRef( );
return pRenderTarget;
}
static const D3DFORMAT pFormats[] =
{
D3DFMT_R32F,
D3DFMT_X8R8G8B8,
D3DFMT_D16,
};
// Do we want to crate a depth stencile?
if( _keFMT == SF_uDepth )
{
// Create a depth stencile texture
IDirect3DSurface9* pSurface = NULL;
if( FAILED( CDX9Renderer::GetDevice( )->CreateDepthStencilSurface( _kuWidth, _kuHeight, pFormats[_keFMT], D3DMULTISAMPLE_NONE, 0, !_bWriteOnly, &pSurface, 0 ) ) )
{
// no
// assert
return NULL;
}
return new CDX9Texture( pSurface, CDX9Renderer::GetDevice( ), true );
}
// Create a render target
IDirect3DTexture9* pTexture = NULL;
//NOTE: The 0 may need to be a 1
if( FAILED( CDX9Renderer::GetDevice( )->CreateTexture( _kuWidth, _kuHeight, 0, D3DUSAGE_RENDERTARGET, pFormats[_keFMT], D3DPOOL_DEFAULT, &pTexture, 0 ) ) )
{
// no
// assert
assert_now( "Failed to texture!" );
return NULL;
}
return new CDX9Texture( pTexture, CDX9Renderer::GetDevice( ) ) ;
}