Sign in to follow this  

Release LPDIRECT3DTEXTURE9*

This topic is 2061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
[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]

Share this post


Link to post
Share on other sites
[color=#282828]IDirect3DTexture9 * will simply hold a single texture, since you are using x files; [/color][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]
[color=#282828][background=rgb(250, 251, 252)][CODE]
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)]}
[/CODE][/background][/color]

[color=#282828][background=rgb(250, 251, 252)]m_dwNumOfMeshMaterials: Number of materials of that corresponding mesh[/background][/color]

Share this post


Link to post
Share on other sites
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;
}
}

Share this post


Link to post
Share on other sites

This topic is 2061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this