I have loaded a mesh .x whit texture in direct3d. Now, how can i do to release LPDIRECT3DTEXTURE9* because if I call the function Release() i getted this error: error C2227: left of '->Release' must point to class/struct/union/generic type.
Thanks and sorry for my bad English.
4 replies to this topic
Sponsor:
#3 Members - Reputation: 264
Posted 23 April 2012 - 08:03 PM
IDirect3DTexture9 * will simply hold a single texture, since you are using x files; IDirect3DTexture9 ** will hold array of textures. You have to loop through that array of texture and then free that textures; here's how it's done:
m_dwNumOfMeshMaterials: Number of materials of that corresponding mesh
for(DWORD dwTextureCount = 0; [/background][/color][color=#282828]dwTextureCount [/color][color=#282828][background=rgb(250, 251, 252)]< m_dwNumOfMeshMaterials; dwSubCount++)
{[/background][/color]
[color=#282828][background=rgb(250, 251, 252)]// Free the corresponding memory of the scene mesh textures[/background][/color]
[color=#282828][background=rgb(250, 251, 252)]if([/background][/color][color=#282828][background=rgb(250, 251, 252)]m_ppD3DSceneMeshTexture[[/background][/color][color=#282828]dwTextureCount[/color][color=#282828][background=rgb(250, 251, 252)]])[/background][/color]
[color=#282828][background=rgb(250, 251, 252)]{[/background][/color]
[color=#282828][background=rgb(250, 251, 252)]m_ppD3DSceneMeshTexture[[/background][/color][color=#282828]dwTextureCount[/color][color=#282828][background=rgb(250, 251, 252)]]->Release();[/background][/color]
[color=#282828][background=rgb(250, 251, 252)]m_ppD3DSceneMeshTexture[[/background][/color][color=#282828]dwTextureCount[/color][color=#282828][background=rgb(250, 251, 252)]] = NULL;[/background][/color]
[color=#282828][background=rgb(250, 251, 252)]}[/background][/color]
[color=#282828][background=rgb(250, 251, 252)]}
m_dwNumOfMeshMaterials: Number of materials of that corresponding mesh
#4 Members - Reputation: 264
Posted 23 April 2012 - 08:06 PM
err...posting it again...
for(DWORD dwTextureCount = 0; dwTextureCount < m_dwNumOfMeshMaterials; dwSubCount++)
{
if(m_ppD3DSceneMeshTexture[dwTextureCount])
{
// Free the corresponding memory of the scene mesh textures
m_ppD3DSceneMeshTexture[dwTextureCount]->Release();
m_ppD3DSceneMeshTexture[dwTextureCount] = NULL;
}
}
for(DWORD dwTextureCount = 0; dwTextureCount < m_dwNumOfMeshMaterials; dwSubCount++)
{
if(m_ppD3DSceneMeshTexture[dwTextureCount])
{
// Free the corresponding memory of the scene mesh textures
m_ppD3DSceneMeshTexture[dwTextureCount]->Release();
m_ppD3DSceneMeshTexture[dwTextureCount] = NULL;
}
}






