- assimpview: do not create a new default texture each time we need one. Turns out memory is not unlimited.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1166 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/5/head
aramis_acg 2012-02-15 23:13:52 +00:00
parent 82f027b01f
commit 745c1035bf
2 changed files with 16 additions and 2 deletions

View File

@ -107,6 +107,11 @@ int CMaterialManager::UpdateSpecularMaterials()
//-------------------------------------------------------------------------------
int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut)
{
if (sDefaultTexture) {
sDefaultTexture->AddRef();
*p_ppiOut = sDefaultTexture;
return 1;
}
if(FAILED(g_piDevice->CreateTexture(
256,
256,
@ -121,8 +126,11 @@ int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut)
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
*p_ppiOut = NULL;
return 0;
}
D3DXFillTexture(*p_ppiOut,&FillFunc,NULL);
sDefaultTexture = *p_ppiOut;
sDefaultTexture->AddRef();
// {9785DA94-1D96-426b-B3CB-BADC36347F5E}
static const GUID guidPrivateData =

View File

@ -54,7 +54,13 @@ private:
// default constructor
CMaterialManager()
: m_iShaderCount (0) {}
: m_iShaderCount (0), sDefaultTexture() {}
~CMaterialManager() {
if (sDefaultTexture) {
sDefaultTexture->Release();
}
}
public:
@ -182,7 +188,7 @@ private:
// each time a shader isn't found in cache and needs to be created
//
unsigned int m_iShaderCount;
IDirect3DTexture9* sDefaultTexture;
};