Reputation: 392
I've been working through a handful of directX tutorials. They all mention D3DXCreateTextureFromFileEx
for loading an image from a file into video memory. However, nobody (that I've seen), talks about how to free up that memory. Can I just call free() on the pointer that is returned?
Upvotes: 2
Views: 576
Reputation: 26259
Like almost all of the DirectX API, when you create a new object, it's returned as a pointer to a COM interface. In your case you get a pointer to an IDirect3DTexture9
interface.
When you want to release these resources, you use the normal COM method for disposing of reference-counted interfaces, by calling Release()
on the pointer:
IDirect3DDevice9 *pTexture = NULL;
D3DXCreateTextureFromFileEx( /* ... */, &pTexture);
// ... use the texture .....
// release interface
pTexture->Release();
pexture = NULL;
Upvotes: 2