Original Post
Hi! I´ve got a little question on reference counting on DirectX. I´m currently using DDraw 6.1 and I´m a little bit confused on when do I have to call the Release() method on an interface.
For example, if I have this code snippet:
LPDIRECTDRAW4 lpDD;
DirectDrawCreate(NULL,&lpDD,NULL);
The reference counting on lpDD increments to one, right? But what if I have a bunch of globals in my program that keep track of all the interfaces created and I make an assigment such as the following one?
LPDIRECTDRAW4 lpDD2; // Suppose this is global.
lpDD2 = lpDD; // Assume lpDD is valid.
Does the reference count increment in this situation? What will I have to do in the shutdown function? This?
if(lpDD) {
lpDD->Release();
lpDD = NULL;
}
or this?
if(lpDD) {
lpDD->Release();
lpDD = NULL;
}
if(lpDD2) {
lpDD2->Release();
lpDD2 = NULL;
}
I hope you can help me. I looked it up in the sdk help but the explanation was not very clear. Thanks in advance!