本文整理汇总了C++中CTexture::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ CTexture::SetName方法的具体用法?C++ CTexture::SetName怎么用?C++ CTexture::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTexture
的用法示例。
在下文中一共展示了CTexture::SetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractTexture
bool CStaticMesh::ExtractTexture(FILE* modelFile, std::vector<CTexture*>& textVector)
{
assert(modelFile);
uint16 length = 0;
char* path;
std::string sPath = "";
//Read Length of the texture path
fread(&length, sizeof(uint16), 1, modelFile);
path = new char[length];
memset(path, 0, length);
//Read Path
fread(path, 1, length, modelFile);
sPath = std::string(path);
CHECKED_DELETE(path);
std::string texName = m_MeshName + "_" + sPath;
CTexture* texture = CORE->GetTextureManager()->GetResource(texName);
if(texture == NULL)
{
texture = new CTexture();
texture->SetName(texName);
if(!texture->Load(sPath))
{
CHECKED_DELETE(texture);
texture = CORE->GetTextureManager()->GetNoTexture();
std::string err = "CStaticMesh::ExtractTexture->No se ha podido crear la textura: " + sPath;
LOGGER->AddNewLog(ELL_WARNING, err.c_str() );
}
}
textVector.push_back(texture);
return true;
}
示例2: CTexture
CTexture * CRenderManager::LoadTexture(char const * _szFileName, D3DCOLOR const _ColorKey)
{
if(NULL == _szFileName)
{
MessageBox(0, "Filename was invalid.", "LoadTexture", MB_OK);
return NULL;
}
// Look if the texture has already been loaded
list<CTexture*>::iterator IterText = m_arrTextures.begin();
for( ; IterText != m_arrTextures.end(); ++IterText)
{
if(0 == strcmp((*IterText)->GetName().c_str(), _szFileName))
return (*IterText);
}
// Look for the first available slot where the struct is NULL
for(IterText = m_arrTextures.begin(); IterText != m_arrTextures.end(); ++IterText)
{
if(NULL == (*IterText))
{
IDirect3DTexture9 * pTexture = NULL;
// Set the texture
if(FAILED(D3DXCreateTextureFromFileEx(m_pDevice, _szFileName, 0, 0, 0, 0, D3DFMT_UNKNOWN,
D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT,
_ColorKey, 0, 0, &pTexture)))
{
MessageBox(0, "Failed to create texture.", "LoadTexture", MB_OK);
return NULL;
}
CTexture * pNew = new CTexture();
std::string szName = _szFileName;
pNew->SetName(szName);
pNew->SetTexture(pTexture);
pNew->SetColor(_ColorKey);
D3DSURFACE_DESC description;
pTexture->GetLevelDesc(0, &description);
pNew->SetWidth(description.Width);
pNew->SetHeight(description.Height);
pNew->SetTexture(pTexture);
(*IterText) = pNew;
return (*IterText);
}
}
IDirect3DTexture9 * pTexture = NULL;
// Set the texture
if(FAILED(D3DXCreateTextureFromFileEx(m_pDevice, _szFileName, 0, 0, 0, 0, D3DFMT_UNKNOWN,
D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT,
_ColorKey, 0, 0, &pTexture)))
{
MessageBox(0, "Failed to create texture.", "LoadTexture", MB_OK);
return NULL;
}
CTexture * pNew = new CTexture();
std::string szName = _szFileName;
pNew->SetName(szName);
pNew->SetTexture(pTexture);
pNew->SetColor(_ColorKey);
D3DSURFACE_DESC description;
pTexture->GetLevelDesc(0, &description);
pNew->SetWidth(description.Width);
pNew->SetHeight(description.Height);
pNew->SetTexture(pTexture);
m_arrTextures.push_back(pNew);
return pNew;
}