• Advertisement

Archived

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

To clip or not to clip?

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

Let''s consider that I have cube which moves on the screen. No collision detection, so if it goes off-screen it returns back from the other side. Like this:
// Check if cube passed border

// Passed left or right border
if(cube.x_right < 0)
{
	cube.x_left = SCREEN_WIDTH;
	cube.x_right = cube.x_left + cube.width;
}
else if(cube.x_left > SCREEN_WIDTH)
{
	cube.x_right = 0;
	cube.x_left = cube.x_right - cube.width;
}

// Passed upper or bottom border
if(cube.y_bottom < 0)
{
	cube.y_top = SCREEN_HEIGHT;
	cube.y_bottom = cube.y_top + cube.height;
}
else if(cube.y_top > SCREEN_HEIGHT)
{
	cube.y_bottom = 0;
	cube.y_top = cube.y_bottom - cube.height;
}
And my question is that should I clip the part which is out of sight? Or is it ok without clipping?

Share this post


Link to post
Share on other sites
Advertisement
if you''re using software rendering, yes, you should clip all polygons that goes out of sight.

Share this post


Link to post
Share on other sites
What if I'm using DirectDraw's blitting function and simple rect which I fill with color? Therefore I'm not using loaded bitmap.

[edited by - constans on January 15, 2004 11:02:21 AM]

Share this post


Link to post
Share on other sites

  • Advertisement