Archived

This topic is now archived and is closed to further replies.

WoX

clipping in dx7

Recommended Posts

WoX    122
I have problems getting the clipping object to work in directdraw this is what I have done IDirectDrawSurface7 *lpBackBuffer,*lpPrimary; IDirectDrawClipper *lpClip; RGNDATA *lpRgnData; RGNDATAHEADER *lpRgnHeader; then I set up the RGNDATAHEADER and RGNDATA structs like this lpRgnHeader->dwSize = sizeof(RGNDATAHEADER); lpRgnHeader->iType = RDH_RECTANGLES; lpRgnHeader->nCount = 1; lpRgnHeader->nRgnSize = 0; lpRgnHeader->rcBound.top = 0; lpRgnHeader->rcBound.left = 0; lpRgnHeader->rcBound.bottom = 600; lpRgnHeader->rcBound.right = 800; lpRgnData->rdh.dwSize = lpRgnHeader->dwSize; lpRgnData->rdh.iType = lpRgnHeader->iType; lpRgnData->rdh.nCount = lpRgnHeader->nCount; lpRgnData->rdh.nRgnSize = lpRgnHeader->nRgnSize; lpRgnData->rdh.rcBound = lpRgnHeader->rcBound; lpRgnData->Buffer[0] = (char)0; lpRgnData->Buffer[1] = (char)600; lpRgnData->Buffer[2] = (char)0; lpRgnData->Buffer[3] = (char)800; I''m not quite sure about the Buffer member in RGNDATA, in MSDN it says Buffer: Specifies an arbitrary-size buffer that contains the RECT structures that make up the region. but the Buffer member is of type char not RECT... anyway, after this I use the IDirectDrawClipper::SetClipList function: lpClip->SetClipList(lpRgnData,0); and then the IDirectDrawSurface7::SetClipper function: lpPrimary->SetClipper(lpClip); but when I run the program it just quits... anyone have done any clipping before and have some code to lend or something cause this is really disturbing thanks in advance

Share this post


Link to post
Share on other sites
Epiphany    122
First you need to allocate memory for RgnData, enough memory for a RgnDataHeader and the number of rects that you are useing. then to copy the rect(''s) into the RgnDate.buffer you need to do a memcopy, not just an assignment statement. I program in delphi so I dont know if the rest of your code is correct. There is an article on this very subject in C, check it out
http://gamedev.net/reference/programming/features/gpgenesis6/

A good game by any other name is still a good game, STOP the RPG mentality

Share this post


Link to post
Share on other sites
C-Junkie    1099
You say the buffer is made up of RECT types, but you don''t use them. just based on what you said, try

// (if you aren''t using C++...then change this but)
RECT *buffer = new RECT[ n ];
buffer[0]->left = 0;
buffer[0]->top = 0;
...
buffer[ n-1 ]->bottom = 0;
lpRgnData->Buffer = (char *)buffer;

just a guess

Share this post


Link to post
Share on other sites