• Advertisement

Archived

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

Simple D3D8 question

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

I have a LPDIRECT3DDEVICE8 object in my D3DClass and another LPDIRECT3DDEVICE8 in my RenderScene Class. I think the two objects is the same because I never call CreateDevice on the second object... I just set it to point at the device object in the D3DClass.
  

bool CApp::Create(HWND MainWnd) 
{
 ...
 
 m_RenderScene.Create(m_Direct3D.GetDevice()); 

 ...
}

bool CRenderScene::Create(LPDIRECT3DDEVICE8 device)
{
  m_lpDevice = device;
  return true;
}

  
My question is: Is it necessary to Relase() the device object in the RenderScene class, or is it enough to just relase the first object? Thanks, Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You can figure this one out yourself. Go to control panel->directx. Then click on the direct3d tab. Change debug output level to the more direction (don''t need to go all the way). This will enable memory reports. If at the end of debugging your program, memory leak errors are reported, then you know you are not releasing everything.

Share this post


Link to post
Share on other sites
if you are simply reusing a pointer:

pMyDevice = CreateDevice()
pCopy = pMyDevice

you don''t need to release twice. If for some reason you decide to do something involving AddRef, you should release:

pMyDevice = CreateDevice()
pCopy = pMyDevice
pCopy->AddRef()


This is good if you have several objects that reuse the same pointer and you want to make sure that one object cleans up after itself, but doesn''t ruin the party for the others. If everyone addrefs and everyone releases, then the pointer only gets released when everyone is done. That''s the whole point...

Share this post


Link to post
Share on other sites
Thanks for your help!

Here is a little more information:

I get this error every time if I run my program in Debug Mode:

Direct3D8: (ERROR) :Total Memory Unfreed From Current Process = 153387 bytes

And I never call AddRef. I dont think the second object is a pointer or not... They are declared exactly the same.

LPDIRECT3DDEVICE8 CDx3D::m_lpDevice;
LPDIRECT3DDEVICE8 CRenderScene::m_lpDevice;

Share this post


Link to post
Share on other sites

  • Advertisement