Sign in to follow this  

Sprite and clipping

This topic is 4595 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'm developing yet another GUI in directX. Not for commercial reasons, but Since DirectX is totally new, this is a good point to start. But is their a way I can do some easy clipping? Something like an easy cliprect? This might be different for each control. kind regards Alexander

Share this post


Link to post
Share on other sites
The easiest is probably to use IDirect3DDevice9::SetScissorRect(). Once a clipping rectangle is set, you can enable/disable the clipping with D3DRS_SCISSORTESTENABLE.

There are other techniques you could use, such as using masks and alpha test; using the stencil buffer; adjusting the vertices in a vertex shader; or manually clipping the input vertices.

Share this post


Link to post
Share on other sites
Hi

Thanks for the Scissor thing.

I'm currently using Managed directX feb 2005 release.
It seems to act a little funny. The code below tries to show what I'm doing.
It clips everything to the second rect. The first sprite is not clipped to big rectangle, but to the small.

What am I forgetting?

sprite.Begin()

device.ScissorRectanle = new Rectangle(0, 0, 50, 50);
device.RenderState.ScissorTestEnable = true;
sprite.draw...
device.RenderState.ScissorTestEnable = false;

device.ScissorRectanle = new Rectangle(0, 0, 10, 10);
device.RenderState.ScissorTestEnable = true;
sprite.drawAnother
device.RenderState.ScissorTestEnable = false;

sprite.End();

Kind regards

Alexander

Share this post


Link to post
Share on other sites
Hi

Thanks for the Scissor thing.

I'm currently using Managed directX feb 2005 release.
It seems to act a little funny. The code below tries to show what I'm doing.
It clips everything to the second rect. The first sprite is not clipped to big rectangle, but to the small.

What am I forgetting?

sprite.Begin()

device.ScissorRectanle = new Rectangle(0, 0, 50, 50);
device.RenderState.ScissorTestEnable = true;
sprite.draw...
device.RenderState.ScissorTestEnable = false;

device.ScissorRectanle = new Rectangle(0, 0, 10, 10);
device.RenderState.ScissorTestEnable = true;
sprite.drawAnother
device.RenderState.ScissorTestEnable = false;

sprite.End();

Kind regards

Alexander

Share this post


Link to post
Share on other sites

This topic is 4595 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.

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