Sign in to follow this  
_Sigma

Anyone have a clipper?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Here's a 2d clipper pseudocode:


if (source rectangle is wholly outside destination rectangle)
bail out
else if (source rectangle wholly inside destination)
just copy the source data to the destination location, scanline by scanline
else 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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks man! I had tried google, but with poor results. Perhaps I was using the wrong search string?! ;)

Cheers

Sigma

Share this post


Link to post
Share on other sites
_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.

Share this post


Link to post
Share on other sites
Sorry, I assumed you would know I was using Tricks of the windows programming gurus as I'm using DirectDraw. My bad. WIll keep it in mind for next time! ;)

And ya, with a few adjustments, that code worked like a dream

Share this post


Link to post
Share on other sites

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