   When I create a device eg LPDIRECT3DDEVICE9, and make copy, is that just a pointer?
  When i create a device in dx, eg using LPDIRECT3DDEVICE9, and then make another LPDIRECT3DDEVICE9 equal the one that one that i created, will it just be pointing to it.for example: LPDIRECT3DDEVICE9 lp_Device;lp_Device->createWhatEver();LPDIRECT3DDEVICE9 copy = lp_Device; //so is this just some kind// of pointer or reference. Like I don't have to//Release this from memory afterwards?lp_Device->Release();Thanks,[edited by - johnnyBravo on February 17, 2004 6:34:10 AM]
  Correct.LPDIRECT3DDEVICE9 is just a pointer to an IDreict3DDevice9 interface. This is more of a C++ question about how pointers work then it is specific to dx9. For example int* i1 = new int(23);now if you do int* i2 = i1;then the following is unecessarydelete i1;delete i2;All you have to do isdelete i1;ORdelete i2;And your memory is freed. Same calse with Release on a d3d device.    | TripleBuffer Software || Plug-in Manager :: System Information Class :: C++ Debug Kit :: DirectX Tutorials :: Awesome Books | ;  There's a little more to this example than just pointers tho.lp_Device is actually a reference to a COM interface - which, in C/C++, is implemented as a pointer.COM uses reference counting - using AddRef and Release - which I suggest you follow if you're going to pass interfaces around and hold multiple copies of them.   [edited by - stubble on February 17, 2004 8:08:11 AM];quote:Original post by stubble  COM uses reference counting - using AddRef and Release - which I suggest you follow if you''re going to pass interfaces around and hold multiple copies of them.Agreed (though it''s a little on the overkill side if the copy is super-temporary). The following code will break: LPDIRECT3DDEVICE9 pDevice = GetDevice();LPDIRECT3DDEVICE9 pSameDevice = pDevice;pDevice->Release();pSameDevice->Release();By the time pDevice->Release(); has finished executing, the device object is, as far as you''re concerned, gone; thus, calling Release on it again (the next line) will probably cause an access violation.To fix it, this would work: LPDIRECT3DDEVICE9 pDevice = GetDevice();LPDIRECT3DDEVICE9 pSameDevice = pDevice; pDevice->AddRef();pDevice->Release();pSameDevice->Release();The basic rule is that the number of calls to Release() must match the number of calls to AddRef() (or Creation functions, which tend to call AddRef internally). ;  the magical word is boost::intrusive_ptr ;  I see thankyou,What I''m doing is Ive created classes for things in direct3d, eg font, sprite, vertex, mesh etc, and they all require the d3d device, so i just make a copy(pointer i think i mean, from my original example) within each class. Would you say this is being efficient, or should I do it some other way?Thanks, 