Sign in to follow this  

[XNA 4] ScissorRectangle and SpriteBatch

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

Did SpriteBatch stop respecting the current ScissorRectangle in XNA 4? Did anything change? My GUI system was highly dependent on ScissorRectangles and seems to have broken when I upgraded to XNA 4 which is a big problem for me. In Xna 3.1 I had to Begin() and End() in my SpriteBatch for each time I changed the ScissorsRectangle which isn't exactly optimal, but it worked and was 'fast enough' for my purposes.

Any ideas or links? I tried googling but have so far been unable to come up with anything.

Share this post


Link to post
Share on other sites
SpriteBatch will certainly use ScissorRectangle. Are you setting the appropriate state blocks to enable it? In the RasterizerState currently applied to the device, ensure ScissorTestEnable is set to true.

Share this post


Link to post
Share on other sites
[source lang="c#"]
[size="2"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]device[/color][/font][/color][/font][/color][/font][font="Consolas"][font="Consolas"].[/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]RasterizerState[/color][/font][/color][/font][/color][/font][font="Consolas"][font="Consolas"] = [/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]new[/color][/font][/color][/font][/color][/font] [font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]RasterizerState[/color][/font][/color][/font][/color][/font][font="Consolas"][font="Consolas"]() { [/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]ScissorTestEnable[/color][/font][/color][/font][/color][/font][font="Consolas"][font="Consolas"] = [/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]true[/color][/font][/color][/font][/color][/font][font="Consolas"][font="Consolas"] };
[/font][/font][/size][size="2"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]device[/color][/font][/color][/font][/color][/font][font="Consolas"][font="Consolas"].[/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]ScissorRectangle[/color][/font][/color][/font][/color][/font][font="Consolas"][font="Consolas"] = [/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][color="#0000ff"]new[/color][font="Consolas"] [/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]Rectangle[color="#000000"](10,10,100,100)[/color][/color][/font][/color][/font][/color][/font][/color][/font][/color][/font][/color][/font][font="Consolas"][font="Consolas"];
spriteBatch.Begin();
[/source]


[/font][/font][/size][font="Consolas"][size="2"][font="Consolas"][size="2"]Is there anything else I should be doing?[/size][/font][/size][/font]



EDIT:
I just realized I had to pass the RasterizerState to Begin(). That fixed it.

Share this post


Link to post
Share on other sites

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