DirectDraw clipper question

Started by
5 comments, last by doynax 19 years, 4 months ago
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?
Advertisement
can any one help with this?
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 ClipperRectangle[] ScreenClip= new Rectangle[1];// Mae a Rect' array to hold clipper infoScreenClip[0]=new Rectangle(-32,-32,832,632);//32 pixel off screen buffer area in all directionsclip.ClipList = ScreenClip;// Set the array just made as the Clip listbackBuffer.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
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.
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 bufferregion_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 valuelpddclipper->SetClipList(region_data, 0);lpddsback->SetClipper(lpddclipper);free(region_data);


This should work for you.
this part here

memcpy(region_data->Buffer, screen_rect, sizeof(RECT) * num_rects);

gives me an error. How mant rects are there i thought there was only one
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 =(

This topic is closed to new replies.

Advertisement