PDA

View Full Version : pointers with directX


Renaud
09-13-2004, 01:03 PM
// How come I can do this????????


LPDIRECTDRAWSURFACE7 lpDDSButtons=NULL;

// surface loading code
....

HDC hdc;
lpDDSButtons->GetDC(&hdc);
COLORREF PreColor = GetPixel(hdc, X-x+normalState.left, Y-y+normalState.top);
lpDDSButtons->ReleaseDC(hdc);
if (PreColor != RGB(0,255,0))
{
return true;
}

// but I can't do this ????

LPDIRECTDRAWSURFACE7* mtempSurface;
mtempSurface = &lpDDSButtons;

HDC hdc;
mtempSurface->GetDC(&hdc);
COLORREF PreColor = GetPixel(hdc, X-x+normalState.left, Y-y+normalState.top);
lpDDSButtons->ReleaseDC(hdc);
if (PreColor != RGB(0,255,0))
{
return true;
}


I get compiler errors, its like it doesnt realize that mtempSurface is a pointer to lpDDSButtons

any help appreciated thanks

anubis
09-13-2004, 02:21 PM
LPDIRECTDRAWSURFACE is a pointer already if you create a pointer to a pointer using -> won't work anymore (that's the problem i guess)

Steven Hansen
09-13-2004, 02:53 PM
This will make it work:


(*mtempSurface)->GetDC(&hdc);


Though why you want a pointer to a pointer to an interface confuses me in this context. If you want a copy of the actual draw surface interface pointer, you should do this instead:


LPDIRECTDRAWSURFACE7 lpDDSButtons;
// ... initialization stuff.

LPDIRECTDRAWSURFACE7 mtempSurface = lpDDSButtons;
mtempSurface->AddRef();


Make sure you release your COM interfaces when you are done with them.