Results 1 to 13 of 13

Thread: DDClippers

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    How can I make a clipper, with cordinates

    top- 4 pixels
    left- 4 pixels
    right - 674 pixels
    bottom - 674 pixels

    I can't use hWnd because I want to clip just part of the window. I don't know how to use
    ddClip->SetClipList(*RGNDATA,0);
    I don't know what to pass for RGNDATA

    THANKS

  2. #2
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    use getwindowrect to get where the window or picturebox is. then you you can move the top left corner down 4 pixels like so:

    rprim.top = rprim.top + 4
    rprim.left = rprim.left + 4

    and then you could change the the bottom and right parts of the rect to what you wanted

    rprim.bottom = 674
    rprim.right= 674

    i hope this is what you were looking for. i've never really used clippers in dx yet.
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I'm assuming you're using C++ since you used C syntax.

    RGNDATA is one of the annoying archaic old DX structures. It contains, among other things, a list of regions you want to clip to, and the number of regions you specify. You have to allocate memory for the array of regions yourself, and free the memory after you've created the cliplist.

    Here are the structure defs:

    PHP Code:
    typedef struct _RGNDATA
    {
         
    RGNDATAHEADER rdh;   // header info
         
    char buffer[1];         // the actual RECT list
    RGNDATA;


    typedef struct _RGNDATAHEADER
    {
         
    DWORD dwSize;    // size of this header in bytes
         
    DWORD iType;       // type of region data
         
    DWORD nCount;    // number of RECTs in buffer[]
         
    DWORD nRgnSize;  // size of buffer[]
         
    RECT rcBound;      // a bounding box around all RECTs
    RGNDATAHEADER
    Harry.

    "From one thing, know ten thousand things."

  4. #4
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    he sounds like he knows what he's doing
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    Thanks HarryW, but how do I use that. I figured out what the syntax for RGNDATA was. I don't know how to make it so it clips a specific rect.

    Thanks

  6. #6
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Well you allocate enough memory for the number of RECTs you want to clip to in RGNDATA::buffer[], and fill your newly allocated array with the RECTs you want.

    The RGNDATAHEADER describes the list of RECTs in buffer[]. You'll need to do something like this:
    PHP Code:
    rdh.dwSize sizeof(rdh);
    rdh.iType RDH_RECTANGLES;
    rdh.nCount NUMBER_OF_RECTS// however many RECTs in your clip list
    rdh.nRgnSize sizeof(RECT)*rdh.nCount;

    // also you need to set rdh.rcBound to a RECT
    // which contains all your clipping regions.  That's
    // not too hard. 
    Then you make the calls you want to create the clipping list, and then free the memory in your RGNDATA structure.
    Harry.

    "From one thing, know ten thousand things."

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    One last question, what do I do for the buffer?

    Thanks

  8. #8
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Well buffer is just an array of RECTs at the end of your RGNDATA structure. Remember, the structure is contiguous in memory when you allocate memory for it, so all you have to do is allocate memory for the entire RGNDATA structure allowing for a RGNDATAHEADER (fixed size), and also enough space for however many RECTs you want to define in your cliplist. So, here's some code to do just that:
    PHP Code:
    RGNDATA *pRegionData

    if(!(pRegionData = (RGNDATA *)malloc(sizeof(RGNDATAHEADER) + NUMBER_OF_RECTS*sizeof(RECT))))
         return(
    ERROR);  // error checking - return an error code if you like

    // now set up pRegionData->rdh, then fill buffer[] with however many RECTS you want

    // DDraw call:
    if(FAILED(lpddclipper->SetClipList(pRegionData0)))
    {    if(!
    pRegionData// shouldn't reasonably be NULL, but check anyway
              
    free(pRegionData)
          return(
    ERROR);  // error checking - return an error code if you like
    }

    // DDraw call:
    if(FAILED(lpdds->SetClipper(lpddclipper)))
    {    if(!
    pRegionData// shouldn't reasonably be NULL, but check anyway
              
    free(pRegionData)
          return(
    ERROR);  // error checking - return an error code if you like
    }

    // now free your allocated memory
    if(!pRegionData// shouldn't reasonably be NULL, but check anyway
         
    free(pRegionData);

    // finished with clipper code and region data 
    Hope that helps, gimme a shout if you need any more
    Harry.

    "From one thing, know ten thousand things."

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    Okay heres what I have, somethings not right, but I don't know what. I got rid of the error checking to make it easier to read

    RECT ClipRect;
    ClipRect.top = 4;
    ClipRect.left =4;
    ClipRect.right = 674;
    ClipRect.bottom = 674;

    lpDD->CreateClipper(0,&ddClipper,NULL);

    RGNDATA *pRegionData;
    pRegionData = (RGNDATA*)malloc(sizeof(RGNDATAHEADER) + sizeof(RECT));

    RGNDATAHEADER rdh;
    rdh.dwSize = sizeof(rdh);
    rdh.rcBound = ClipRect;
    rdh.iType =RDH_RECTANGLES;
    rdh.nCount =1;
    rdh.nRgnSize =sizeof(RECT);

    pRegionData->rdh=rdh;

    ddClipper->SetClipList(pRegionData,0);
    ddsBuffer->SetClipper(ddClipper);

    free(pRegionData);

    Thanks a Lot!

  10. #10
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    You need to put ClipRect in pRegionData->buffer[0].

    Code:
    pRegionData->buffer[0] = ClipRect;
    Harry.

    "From one thing, know ten thousand things."

  11. #11
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Oh, just realised you might get a type error since buffer is a char (I really don't know why... a RECT would be more sensible, but then it's an odd structure anyway). I also realised that Buffer should be capitalised (d'oh!).

    This ought to work anyway:

    Code:
    memcpy(pRegionData->Buffer, &ClipRect, sizeof(RECT));
    Harry.

    "From one thing, know ten thousand things."

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    Works Now, Thanks a Lot!! When I finish my game (couple of days) I'll post it so you can take a look at it

  13. #13
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Cool, no problem
    Harry.

    "From one thing, know ten thousand things."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width