Jump to content
  • Advertisement

Archived

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

Neen10do

Clipping in Fullscreen?

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

im using directx7 to create a shooter, and when surfaces go outside the scope of the screen (or even partially) the game locks up. how would i implement to be able to 1. show partial sprites and 2. keep it from locking up when things go completely off screen? i code therefore i am.

Share this post


Link to post
Share on other sites
Advertisement
You need to clip the rectangle you are writing so that they
never pass the borders, just giving the illusion that they are.

Just to give you an illustration, try and see the point in this.

  
|-----------------|
| |
| |
| |
| |
| |----|--|
| | | |
|-----------------|B |
| A |
|-------|C
D


____________________________________________________________
Try RealityRift at www.planetrift.com
Feel free to comment, object, laugh at or agree to this. I won't engage in flaming because of what I have said.
I could be wrong or right but the ideas are mine.



[edited by - MichaelT on February 9, 2003 7:01:48 PM]

Share this post


Link to post
Share on other sites
yeah, i got it. this works.


  
void cSprite::ScreenClip(RECT &rcRect)
{

int left = rcRect.left;
int right = rcRect.right;
int top = rcRect.top;
int bottom = rcRect.bottom;

//BOTTOM CLIP

if(myY + myHeight > 480)
{
bottom = bottom - ((myY + myHeight) - 480);

SetRect(&rcRect,left,top,right,bottom);
}

//RIGHT CLIP

if(myX + myWidth > 640)
{
right = right - ((myX + myWidth) - 640);

SetRect(&rcRect,left,top,right,bottom);
}

//LEFT CLIP

if(myX < 0)
{
//Left is a negitive number, which moves the left boundary to the right

left = left - myX;

SetRect(&rcRect,left,top,right,bottom);
}

//TOP CLIP

if(myX < 0)
{
//TOP is a negitive number, which moves the TOP boundary down

top = top - myY;

SetRect(&rcRect,left,top,right,bottom);
}
}


i code therefore i am.

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!