• Announcements

Archived

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

Where can I learn DirectDraw Clipping ?

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 on other sites
Have a look at the source in the CDX Library at www.cdxlib.com

Share on other sites
Ugh...

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 !

Thanks

Destroyer

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,

Dave

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... !

Thanks,

Destroyer

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

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 spritercRect.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 rectangleif(x < 0){ rcRect.left = -x; x=0;}// do the same to the top coordinate of the rectangleif(y < 0){ rcRect.top = -y; y=0;}// 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; g_pDDSBack->BltFast(x,y,surface,&rcRect,DDBLTFAST_NOCOLORKEY);

• Forum Statistics

• Total Topics
627757
• Total Posts
2978951

• 11
• 10
• 10
• 23
• 14