Jump to content
  • Advertisement
Sign in to follow this  

Issue with scissorrectangle

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

I'm stumped on how to fix this issue.

I draw the map using a scissor rect during spriteBatch and later I draw my paperdoll however the scissor rect for the map is cutting off the paperdoll model somehow. Here's an example of it:



I'm drawing part of the map via:

[source lang="csharp"]sb.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.None, scissorRS);

scissorRect.X = mapElementRect.X;
scissorRect.Y = mapElementRect.Y;
scissorRect.Width = mapElementRect.Width;
scissorRect.Height = mapElementRect.Height;
// Make sure rect doesn't go out of bounds of screen
if (scissorRect.X + scissorRect.Width > screenWidth - 1)
scissorRect.Width = screenWidth - scissorRect.X;
if (scissorRect.Y + scissorRect.Height > screenHeight - 1)
scissorRect.Height = screenHeight - scissorRect.Y;

sb.GraphicsDevice.ScissorRectangle = scissorRect;[/source]

The paperdoll is drawn after the map. I believe it has to do with depth as setting device.DepthStencilState to none draws the model fully but of course it's inside out at that point. However I set depth to none when drawing the map.

Any ideas?

EDIT : Ok I feel silly. After combing my code for the past two hours there was one line when drawing the map outline that was setting DepthStencilState to Default during spritebatch.Begin() that I kept missing. Case closed! Edited by belgreth

Share this post

Link to post
Share on other sites
Do you have z-sorting enabled? If so, you have to make sure the z of your model is higher than the z of the map.

Share this post

Link to post
Share on other sites
I don't believe so. Isn't that what SpriteSortMode.Deferred means? No z sorting, just draw everything on top of each other in draw call order? Plus I'm not specifying a depth when drawing any element

[source lang="csharp"]sb.Draw(mapBiomeColorTexture, mapRect, new Color(1, 1, 1, 0.2f)); [/source]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!