PDA

View Full Version : quick question about texture pointers


starstutter
01-02-2009, 11:04 PM
Lets say I have 2 textures declared:

LPDIRECT3DTEXTURE9 texObject;
LPDIRECT3DTEXTURE9 texPointer;

Now first off I realize both of these are pointers (despite the names given), but then I create a texture in one of them:

d3ddev->CreateTexture(texObject);

Now, I say:

texPointer = texObject;

I know that texPointer will not equal the actual texture itself (only the pointer to it) but here's my question:

do I now have to call the Release() function on texPointer to avoid a memory leak? Or is this taken care of when I later release texObject. They both point to the same place so I would think that releasing one would cover any memory problems, however I'm not sure and I want to be certain that making it texPointer equal to a LPDIRECT3DTEXTURE9 will not cause a memory leak if not released.

Reedbeta
01-02-2009, 11:13 PM
No, you do not need to call Release(), because you have not called AddRef(). Direct3D can't know when you make a copy the pointer in your own application; LP... types are just plain old raw pointers, without any additional intelligence.

starstutter
01-03-2009, 12:02 AM
that's what I figured, just making sure. :)
Thanks for the help.