4

I have a 32x32 sprite for a pixel art based game but when I scale the sprite up, it becomes very blurred, I have read about online and I believe the solution lies somewhere in SamplerState.

I've had a look on the MSDN and around StackOverflow and Gamedev but found nothing useful to a beginner like me. A few code sample but I have no idea where I could work them into my project.

I'm not providing any of my code yet since I'm sure it isn't of any use. All I want is someone to explain how or even just throw some simpler code at me. I don't mind which, most likely I would like to have it explained becuase then I would know how to do it in the future.

Pyroglyph
  • 164
  • 5
  • 14
  • 2
    Are you using the `SpriteBatch`? [This question](http://stackoverflow.com/questions/9215027/nearest-neighbor-zoom) might be of interest. – Nico Schertler Aug 05 '14 at 18:08
  • 1
    Thanks, that was exactly what was happening, also I wasn't sure what to put for all the other parameters but `spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise);` (pasted from linked question) worked perfectly! – Pyroglyph Aug 05 '14 at 18:13

1 Answers1

11

SpriteBatch.Begin can take a SamplerState parameter. All you do is pass in SamplerState.PointClamp

SpriteBatch.Begin (SpriteSortMode, BlendState, SamplerState.PointClamp, DepthStencilState, RasterizerState)

Just like that but replace SpriteSortMode, BlendState, DepthStencilState, and RasterizerState with your desired values. Some can take null if you do not wish to use it.

J-ho
  • 238
  • 3
  • 17
PaulBinder
  • 2,022
  • 1
  • 16
  • 26