- 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-9d2fd5bffc1fpull/5/head
parent
82f027b01f
commit
745c1035bf
|
@ -107,6 +107,11 @@ int CMaterialManager::UpdateSpecularMaterials()
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut)
|
int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut)
|
||||||
{
|
{
|
||||||
|
if (sDefaultTexture) {
|
||||||
|
sDefaultTexture->AddRef();
|
||||||
|
*p_ppiOut = sDefaultTexture;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if(FAILED(g_piDevice->CreateTexture(
|
if(FAILED(g_piDevice->CreateTexture(
|
||||||
256,
|
256,
|
||||||
256,
|
256,
|
||||||
|
@ -121,8 +126,11 @@ int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut)
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
|
|
||||||
*p_ppiOut = NULL;
|
*p_ppiOut = NULL;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
D3DXFillTexture(*p_ppiOut,&FillFunc,NULL);
|
D3DXFillTexture(*p_ppiOut,&FillFunc,NULL);
|
||||||
|
sDefaultTexture = *p_ppiOut;
|
||||||
|
sDefaultTexture->AddRef();
|
||||||
|
|
||||||
// {9785DA94-1D96-426b-B3CB-BADC36347F5E}
|
// {9785DA94-1D96-426b-B3CB-BADC36347F5E}
|
||||||
static const GUID guidPrivateData =
|
static const GUID guidPrivateData =
|
||||||
|
|
|
@ -54,7 +54,13 @@ private:
|
||||||
|
|
||||||
// default constructor
|
// default constructor
|
||||||
CMaterialManager()
|
CMaterialManager()
|
||||||
: m_iShaderCount (0) {}
|
: m_iShaderCount (0), sDefaultTexture() {}
|
||||||
|
|
||||||
|
~CMaterialManager() {
|
||||||
|
if (sDefaultTexture) {
|
||||||
|
sDefaultTexture->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -182,7 +188,7 @@ private:
|
||||||
// each time a shader isn't found in cache and needs to be created
|
// each time a shader isn't found in cache and needs to be created
|
||||||
//
|
//
|
||||||
unsigned int m_iShaderCount;
|
unsigned int m_iShaderCount;
|
||||||
|
IDirect3DTexture9* sDefaultTexture;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue