Archived

This topic is now archived and is closed to further replies.

MrNeedHelp

STL vectors + Textures

Recommended Posts

MrNeedHelp    122
Would i have problems if i used an STL vector of LPDIRECT3DTEXTURE9 objects for rendering ? Also , since those vectors release themselfs , how would i release the Texture objects ? Looping throught the vector and calling release ?

Share this post


Link to post
Share on other sites
mickey    100
i guess there won''t be any problem since a vector is just a data structure and a data structure hold stuffs, like a LPDIRECT3DTEXTURE9

you can release a LPDIRECT3DTEXTURE9 object when you pop a vector by declaring a pointer to it and then releasing it,

ie,

LPDIRECT3DTEXTURE9 p = vector.pop();
p->Release();

eeh.., i guess this would work.




http://www.angrysoft.com/
Get SMS Counter and Call Counter for Nokia 7650/3650

Share this post


Link to post
Share on other sites
reaptide    226
Yep. Using an STL container works quite nicely. Using one straight though will require you to call Release() for each texture before the container goes out of scope.

Instead you could encapsulate the LPDIRECT3DTEXTURE9 object in a texture object class. That way you could have the Release() in the destructor and it will be called when the STL container goes out of scope.

[edited by - Reaptide on May 28, 2003 2:58:28 PM]

Share this post


Link to post
Share on other sites
Kippesoep    892
You''d have to make sure you AddRef in your copy constructor, though, or the textures may get released too early when the vector resizes.

Putting the pointers directly into the vector won''t have this problem, but necessitates the manual iteration and Release calls.

Share this post


Link to post
Share on other sites