Jump to content
  • Advertisement
Sign in to follow this  
DvDmanDT

[XNA 4] ScissorRectangle and SpriteBatch

This topic is 2602 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
Advertisement
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#"]
[font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]device[/font][/font][/font][font="Consolas"][font="Consolas"].[/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]RasterizerState[/font][/font][/font][font="Consolas"][font="Consolas"] = [/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]new[/font][/font][/font] [font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]RasterizerState[/font][/font][/font][font="Consolas"][font="Consolas"]() { [/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]ScissorTestEnable[/font][/font][/font][font="Consolas"][font="Consolas"] = [/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]true[/font][/font][/font][font="Consolas"][font="Consolas"] };
[/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]device[/font][/font][/font][font="Consolas"][font="Consolas"].[/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"]ScissorRectangle[/font][/font][/font][font="Consolas"][font="Consolas"] = [/font][/font][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][font="Consolas"][color="#010001"][color="#0000ff"]new[font="Consolas"] [/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]Rectangle[color="#000000"](10,10,100,100)[/font][/font][/font][/font][/font][/font][font="Consolas"][font="Consolas"];
spriteBatch.Begin();
[/source]


[/font][/font][font="Consolas"][font="Consolas"]Is there anything else I should be doing?[/font][/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
Sign in to follow this  

  • 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!