vector of LPDIRECT3DTEXTURE9
Hi,
I have a question about the functioning of vectors and how this relates to directX's LPDIRECT3DTEXTURE9. I made a vector containing LPDIRECT3DTEXTURE9. I fill the vector by first loading such texture in a 'buffer' and then using push_back. Is is necessary to release the 'buffer' (I hope it is not because if it is it messes up my app :p)
Thanks
A_B
Yes, it is. You must call Release() on all interfaces that you create or AddRef() manually. So at cleanup time, you'll want to loop over each texture in the vector and call Release() on it.
yesyes I do that but I mean do I have to release the buffertexture itself I 'push_backed' to the vector:
buffer->Release();
and later:
vector[pos]->Release();
Thanks
A_B
buffer->Release();
and later:
vector[pos]->Release();
Thanks
A_B
Quote:Original post by A_BYou need to have one Release() for every creation of the texture. You don't need to if you just push_back'd onto a vector, a LPDIRECT3DTEXTURE9 is just a pointer, adding it to a vector will not increase its reference count.
yesyes I do that but I mean do I have to release the buffertexture itself I 'push_backed' to the vector:
buffer->Release();
and later:
vector[pos]->Release();
Thanks
A_B
You can treat it pretty much like any class allocated with new - you need to delete it exactly once, once you're finished using it.
Alternately, use a vector of smart pointers like ATL's CComPtr and let that worry about calling AddRef() and Release().
Quote:Original post by A_B
is that alternatively or preferably?
Perferably, in my opinion. It's quite liberating to free yourself from all of the AddRef and Release nonsense. [smile]
Quote:Original post by MJPYeah, SlimDX is pretty awesome. [grin]Quote:Original post by A_B
is that alternatively or preferably?
Perferably, in my opinion. It's quite liberating to free yourself from all of the AddRef and Release nonsense. [smile]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement