Jump to content
  • Advertisement
Sign in to follow this  
Animaxander

Sprite and clipping

This topic is 4758 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!