Release LPDIRECT3DTEXTURE9*

Started by
3 comments, last by MefistoManna 11 years, 12 months ago
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.
Advertisement
[font=courier new,courier,monospace]LPDIRECT3DTEXTURE9 is IDirect3DTexture9*[/font]
so
[font=courier new,courier,monospace]LPDIRECT3DTEXTURE9* is IDirect3DTexture9**[/font]

[font=courier new,courier,monospace]IDirect3DTexture9** tex; tex->Release();//error C2227[/font]
[font=courier new,courier,monospace]IDirect3DTexture9* tex; tex->Release();[/font]
[color=#282828]IDirect3DTexture9 * will simply hold a single texture, since you are using x files; [color=#282828][background=rgb(250, 251, 252)]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:[/background]
[color=#282828][background=rgb(250, 251, 252)]
for(DWORD dwTextureCount = 0; [/background][color=#282828]dwTextureCount [color=#282828][background=rgb(250, 251, 252)]< m_dwNumOfMeshMaterials; dwSubCount++)
{[/background]
[color=#282828][background=rgb(250, 251, 252)]// Free the corresponding memory of the scene mesh textures[/background]
[color=#282828][background=rgb(250, 251, 252)]if([/background][color=#282828][background=rgb(250, 251, 252)]m_ppD3DSceneMeshTexture[[/background][color=#282828]dwTextureCount[color=#282828][background=rgb(250, 251, 252)]])[/background]
[color=#282828][background=rgb(250, 251, 252)]{[/background]
[color=#282828][background=rgb(250, 251, 252)]m_ppD3DSceneMeshTexture[[/background][color=#282828]dwTextureCount[color=#282828][background=rgb(250, 251, 252)]]->Release();[/background]
[color=#282828][background=rgb(250, 251, 252)]m_ppD3DSceneMeshTexture[[/background][color=#282828]dwTextureCount[color=#282828][background=rgb(250, 251, 252)]] = NULL;[/background]
[color=#282828][background=rgb(250, 251, 252)]}[/background]
[color=#282828][background=rgb(250, 251, 252)]}
[/background]

[color=#282828][background=rgb(250, 251, 252)]m_dwNumOfMeshMaterials: Number of materials of that corresponding mesh[/background]
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;
}
}
Thanks...now it works perfectly

This topic is closed to new replies.

Advertisement