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
Simple D3D8 question
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.
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.
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...
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...
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;
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;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement