Jump to content
  • Advertisement
Sign in to follow this  
A_B

vector of LPDIRECT3DTEXTURE9

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

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


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

Share this post


Link to post
Share on other sites
Quote:
Original post by A_B
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 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.
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.

Share this post


Link to post
Share on other sites
Alternately, use a vector of smart pointers like ATL's CComPtr and let that worry about calling AddRef() and Release().

Share this post


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

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP
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]
Yeah, SlimDX is pretty awesome. [grin]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!