Sign in to follow this  

DirectDraw clipper question

This topic is 4744 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I read in some psot that you can not use a clipper in fullscreen. I set up a clipper in fullscreen so that my sprites will not disaper when there only on half way off the screen and also so my tile map would display the edges. so my question is what is the proper way to set up a clipper in fullscreen mode?

Share this post


Link to post
Share on other sites
I know your using C++ but if its of any help heres how its done in C# (hope you can "decode it")
you need to declare a Clipper called clip(or what ever you want)

then do this in your DDraw surface set up:

clip = new Clipper(); // create a new Clipper
Rectangle[] ScreenClip= new Rectangle[1];// Mae a Rect' array to hold clipper info
ScreenClip[0]=new Rectangle(-32,-32,832,632);//32 pixel off screen buffer area in all directions
clip.ClipList = ScreenClip;// Set the array just made as the Clip list
backBuffer.Clipper= clip;//Set the Back Buffers clipper to our new clipper



I know it seems odd to make an array of 1 for the clipplist but when i tried to assign ScreenClip as a single rectanlge it gave me an error about not being to convert Rectangle[] to Rectanlge.
Like i said i know its not C++ but i hopeit offers an insight into what your after

Share this post


Link to post
Share on other sites
I am not sure how to translate that to c++ because this is what I have for my clipper so far but I know I need a clip list

g_pdd->CreateClipper(0,&g_pddclipper,NULL); //new clipper I think
g_pddclipper->SetHWnd(0,hwnd);//can I put rect here or do I have to leve hwnd
lpBackBuffer->SetClipper(g_pddclipper);//this puts the clipper to the backbuufer that every thing gets blt to.

So I am not wht my right side of the window can keep going but when I go down I get just a bunch of garbge

I think it has to do with my clipper but I am not sure.

Share this post


Link to post
Share on other sites
You can indeed set a clipper to a fullscreen DirectDraw program. You do need extra function calls if your clipper is attached to a windowed program, though. (Your second function in your last post is one you should only call when setting up a windowed clipper).

Here is the code you need:


RECT screen_rect = {0, 0, screen_width, screen_height};

LPDIRECTDRAWCLIPPER lpddclipper;
LPRGNDATA region_data;
int index;

lpddsback->CreateClipper(0, &lpddclipper, NULL);

// lpddsback is a pointer to your back buffer

region_data = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+ sizeof(RECT));
memcpy(region_data->Buffer, screen_rect, sizeof(RECT) * num_rects);

region_data->rdh.dwSize = sizeof(RGNDATAHEADER);
region_data->rdh.iType = RDH_RECTANGLES;
region_data->rdh.nCount = 1;
region_data->rdh.nRgnSize = sizeof(RECT);

region_data->rdh.rcBound.left = 32000; // ridiculously large value
region_data->rdh.rcBound.top = 32000; // ridiculously large value
region_data->rdh.rcBound.right = -32000; // ridiculously negative value
region_data->rdh.rcBound.bottom = -32000;// ridiculously negative value

lpddclipper->SetClipList(region_data, 0);
lpddsback->SetClipper(lpddclipper);

free(region_data);




This should work for you.

Share this post


Link to post
Share on other sites
Quote:
Original post by kingpinzs
gives me an error. How mant rects are there i thought there was only one

There's really no limit. As many as needed to display your program without overdrawing anything that's on top.
And while you might get away without using clippers in fullscreen you probably should, otherwise always-on-top windows will start to flicker or even become completely hidden.
You simply can't believe how many games keep hiding my WinAmp window =(

Share this post


Link to post
Share on other sites

This topic is 4744 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this