Jump to content
  • Advertisement

Archived

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

aker_jus

Releasing d3d interface

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

Hello, I am wondering, if I use: LPDIRECT3D9 d3d9 = something->GetDirect3D(); Do I have to release this d3d9 instance too, or do I just release the instance I first created with Direct3DCreate9? This applies to other interfaces too. Thanx

Share this post


Link to post
Share on other sites
Advertisement
i don''t know anything about the managed dx9 if thats what you are using, but as long as its not creating a totally new interface, ie its returning the pointer to an already existing interface, then no. you only have to release it once.

Share this post


Link to post
Share on other sites
I have not tested how DirectX handles this, but DirectX is made by Mircosoft and Microsoft has a page which states that you must call Release on it.

See "Reference-Counting Rules" Rule 1d in http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncomg/html/msdn_therules.asp

Share this post


Link to post
Share on other sites
then just use a saferelease macro and dont worry about it. as long as you initialize all of the interfaces to null before trying to create/get them:


#define SafeRelease(x) { if(x) { (x)->Release(); (x) = NULL; }}

just make sure you initialize the LPDIRECT3D9 to null, so in your example:

LPDIRECT3D9 d3d9 = NULL;
d3d9 = something->GetDirect3D();

then later on, when you want to release it:

SafeRelease(d3d9);


Share this post


Link to post
Share on other sites

  • 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!