Jump to content


pointers with directX


2 replies to this topic

#1 Renaud

    New Member

  • Members
  • Pip
  • 1 posts

Posted 13 September 2004 - 07: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

#2 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 13 September 2004 - 08: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)
If Prolog is the answer, what is the question ?

#3 Steven Hansen

    Member

  • Members
  • PipPip
  • 86 posts

Posted 13 September 2004 - 08: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users