Jump to content
  • Advertisement
Sign in to follow this  
MTclip

Need to release ???

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

question... I creating a wrapper class for D3dxsprite.. example::
#pragma once

class CSprite
{
public:
	LPD3DXSPRITE		m_sprite;
	LPDIRECT3DDEVICE9        m_pDevice;
	BOOL			isCreated;
      //////////////////////////////////////////
	CSprite(LPDIRECT3DDEVICE9 device);
	~CSprite(void);
	HRESULT create()
	HRESULT setDevice(LPDIRECT3DDEVICE9 device)
	HRESULT setTexture(CTexture *texture)
};

my question has to do with the "m_pDevice" upon instantiation of the "sprite" I set the m_pDevice equal to the device sent in the constructor... So do i need to call the LPDIRECT3DDEVICE9->Release() for "m_pDevice" when i am done with the sprite???? .. .. what i really wanted to do was make "m_pDevice" a "LPDIRECT3DDEVICE9 * " but i had problems getting this to work... ;P

Share this post


Link to post
Share on other sites
Advertisement
Unless you are doing m_pDevice->AddRef() in the constructor, no. Simply making a copy of a pointer will not increase an interface's reference counter. The only time that will happen is when D3D code explicitly increases it, which you have to watch out for. For example, if you call IDirect3DDevice9::GetSurfaceLevel() you must eventually release the returned surface, because it increases that surface's reference count.

Remember, a resource is only actually ever deleted when it's reference count reaches 0. So you could call Release() on a D3DDevice 5 times, without it being deleted (just make sure it has 5 ref counts first [smile]).

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!