Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Where can I learn DirectDraw Clipping ?

This topic is 6231 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

Hi, I was wondering where I could find any resource that would show me how to clip under DirectDraw. I know it uses a IDIRECTDRAWCLIPPER interface and all of that - I just need help calling the functions and wondering what half of the fields of that stupid RGNDATA structure that I have to fill in and all the other techinical stuff I''m still not sure of. I tried doing it myself with the best guesses on what does what... and I couldn''t figure it out. I need something a little more explanatory then the msdn library as well and the DirectX7 docs... they''re a little too vague and no of their samples shows how to clip! Thanks, Destroyer

Share this post

Link to post
Share on other sites

I downloaded the source and I couldn''t find anything... I coudln''t even browse it properly since I could compile the .lib file. Eeeessh...

Any other resources - Anything - anyone !



Share this post

Link to post
Share on other sites
I learned about DDraw clipping from Ian Parberry''s book:

Learn Computer Game Programming with DirectX 7.0

It was a great book as far as writing a small game and he covered clipping ok. Andre Lamothe''s book Tricks of the Game Programming Guru''s book is also very good but slightly dated. (DirectX 6.0)

Good luck,


Share this post

Link to post
Share on other sites
I have Andre Lamothe''s book but it isn''t very good when it comes to explaining clipping and he even said "it just makes more sencse when you look at the code" - but when I tried using the function - I didn''t work! The description was also way to vague for me to come up with my own - I tried... but it never worked...

Ack ... any resources that come free

I really don''t want to buy an entirely new book to just learn Direct Draw Clipping... !



Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Take a look at the Game Programming Genesis articles on this very site. I think clipping is covered
in one of them.

Share this post

Link to post
Share on other sites
Well this is how I do clipping, I don''t use the DDraw Clipper b/c I think it just make things more complicated. However, you will have to use a clipper if you want to do things with GDI, but I''ll assume you just want to clip sprites.

Here''s some code from a function to draw a sprite that performs clipping:

RECT rcRect;
rcRect.left = 0;
rcRect.top = 0;
// dx and dy are the width and height of the sprite

rcRect.right = dx;
rcRect.bottom = dy;

// Culling - the sprite won''t be displayed at all b/c it is fully off the screen.

if(x > 800) return FALSE;
if(y > 600) return FALSE;
if(x <= -dx) return FALSE;
if(y <= -dy) return FALSE;

// Clipping - alters the sprites rectangle to display

// only part of the sprite

// the sprite''s left coordinate is less than 0, therefore

// change the rectangle''s left coordinate to negative

// the sprite''s left coordinate which gives a positive

// value and shrinks the left side of the rectangle

if(x < 0)
rcRect.left = -x;

// do the same to the top coordinate of the rectangle

if(y < 0)
rcRect.top = -y;

// the sprite''s top/left coordinate + width/height = a value

// greater than the width/height of the screen. Therefore it

// has to be clipped by doing width/height of the screen %

// coordinate. In this case the screen is 800x600. The value

// of the operation will shrink the width/height of the

// rectangle to the appropiate value.

if(x+dx > 800)
rcRect.right = 800%x;
if(y+dy > 600)
rcRect.bottom = 600%y;


Digital Radiation

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!