Sign in to follow this  
codingsolo

Failing to Release() IDirect3DTexture9 from .X file

Recommended Posts

My Resource Manager is calling a shutdown on my X files and it seems that even though it is calling Release() on the last texture, it isn't affecting it. The .X file has a total of 4 materials in it. The first 3 textures Release() perfectly fine, changing to 0xfeeefeee after the call, but the last one remains unchanged. I have profiled it in PIX to confirm that it isn't releasing. Any experience on what is going on?
while(xFiles.size())
    {
        XFile* sfds = xFiles.back();

        unsigned int count = xFiles.back()->nNumMats;
        for(unsigned int i=0; i<count; i++)
        {
            if (LPDIRECT3DTEXTURE9 temp = xFiles.back()->pMeshTextures[i])
            {
                temp->Release();
                temp = NULL;
            }
           
        }
        SAFE_DELETE_ARRAY(xFiles.back()->pMeshTextures);
        SAFE_DELETE_ARRAY(xFiles.back()->pMeshMaterials);
        SAFE_RELEASE(xFiles.back()->pMesh);
       
        SAFE_DELETE(xFiles.back());
        xFiles.pop_back();
    }


coding solo

Share this post


Link to post
Share on other sites
Your last call SetTexture() may result it.
SDK reference told that: when you chancel your applicon, you should call SetTexture(0), else, the reference to the texture resource will not be zero. so the texture would not be released in fact.

Share this post


Link to post
Share on other sites

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