Jump to content
  • Advertisement
Sign in to follow this  
fero2004

Release Problem

This topic is 3331 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

HRESULT DrawMesh(D3DXMESHCONTAINER_EX *pMesh) { IDirect3DDevice9 *pD3DDevice; ...... ....... //Get the Device is global variable ? pMesh->MeshData.pMesh->GetDevice(&pD3DDevice); ..... //here he realeased pD3DDevice->Release(); // Return success return S_OK; } why he also can use Device? code comes from[Advanced Animation with DirectX]

Share this post


Link to post
Share on other sites
Advertisement
When the mesh is created, you have to pass in the device. So obviously, the mesh just keeps it's own reference to the device and that's what you're getting back.

Share this post


Link to post
Share on other sites
pMesh->MeshData.pMesh->GetDevice(&pD3DDevice);

This line gets the D3D device associated with the mesh, storing it into the pointer declared just above this line.

If you read the docs, you will see that the device's reference count is increased by this call. Therefore, you need to Release it to ensure the device won't leak.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!