Anyone have a clipper?

Started by
9 comments, last by _Sigma 19 years, 6 months ago
I know this has been asked a bunch, and I've tried the forum search, but no one really had an answer... I'm using André Lamoth's clipper, and although he is a brilliant writer, his code samples are shit, and don't really work(although some are really great!) His clipper, from what I've heard, and my personal experiance, is that it just doesn't work. Does anyone have a DirectDraw clipper code I could "Borrow"? OR know of where I can find a good clipper tutorial? Cheers Sigma
Advertisement
Please? Anyone?!
What is a clipper (there are more meanings of it)? And which André LaMothe book are you talking about?

It helps if you not only explain your problem, but also your situation. You have to understand we're not all reading the same books and doing the same things, although some might have in the past, you never know if they understand what you mean.

Har! [wink]
Here's a 2d clipper pseudocode:

if (source rectangle is wholly outside destination rectangle)bail outelse if (source rectangle wholly inside destination)just copy the source data to the destination location, scanline by scanlineelse if (source edge overlaps destination edge){calculate the amount of overlapping pixels by comparing the distance between the rectangle edges;from source, copy only those pixels to the destination surface which are inside both rectangles}


It's not actually very difficult, if you think it like this. However, this is essentially the algorithm that - for example - DirectDraw clipper uses internally.

EDIT: By the way, if I remember correctly, DDraw7 has a built-in clipper object that performs this automatically, given you initialize it and bind it to a destination surface object. You may not need to write your own clipper!

Niko Suni

Well, most people have read LaMoth's book.

I know what the clipper is, and there IS a DD cliiper object, but what i'm asking is if anyone has a tutorial on how to give it the bounding rect and everything, as my current algorithm isn't working! ;)

>It helps if you not only explain your problem, but also your situation.

I did. :)

Cheers

Sigma
There are tons of tutorials available on the internet. A little time with Google goes a long way.

Here is one tutorial I found in less than 2 minutes through Google.
Thanks man! I had tried google, but with poor results. Perhaps I was using the wrong search string?! ;)

Cheers

Sigma
+directdraw +clipper

Worked like a champ.
Nice.

That code worked fine after a few tweaks. Thx


Sigma
_Sigma, LaMothe has written multiple books. So it's smarter if you mention the title instead of refering to it as 'LaMothe's book'.

Anyway, glad to see you found the solution.

This topic is closed to new replies.

Advertisement