Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a "problem" with XNA 4 and spriteBatch. When I draw a rectangle and rotate it, the sides get quite pixelated and look bad: example:

What do I need to do to make the edges look smooth?

spriteBatch.Draw(box, new Rectangle(350, 350, 100, 100), null, Color.Red,MathHelper.ToRadians(65), new Vector2(50, 50), SpriteEffects.None, 0.0F);

EDIT: Found the solution.

As Tetrad's comment suggested, one needs to activate anti-aliasing. Under XNA4.0 you can use this code

GraphicsDeviceManager graphics;
graphics.PreferMultiSampling = true;
graphics.ApplyChanges();
share|improve this question
3  
What you're seeing is "aliasing". You need to turn on anti-aliasing, but I don't know how to do that with XNA. –  Tetrad Oct 21 '11 at 20:26
    
Does ApplyChanges() do anything special? I set the graphics settings on game initialization with and without it and don't notice a difference. –  ChrisC Oct 21 '11 at 21:06
    
If you have a solution, please post it as an answer and mark it as the accepted answer - it's ok, you're allowed to do that! :) –  doppelgreener Oct 27 '11 at 14:01

2 Answers 2

You need to activate anti-aliasing on your rendering device:

/* Your graphics device manager */
GraphicsDeviceManager gdm;
/* ... */
gdm.Device.RenderState.MultiSampleAntiAlias = true;
/* optional: */
gdm.Device.PresentationParameters.MultiSampleType =  MultiSampleType.SixteenSamples;
gdm.Device.PresentationParameters.MultiSampleQuality = 8;
share|improve this answer
    
There is no RenderState/Device under the GraphicsDeviceManager in XNA4.0! –  Pruit Oct 21 '11 at 20:53
    
Try "gdm.PreferMultisampling = true;" and possibly gdm.GraphicsDevice.PresentationParameters.MultiSampleCount = 8; –  Jason Goemaat Oct 21 '11 at 21:01

did you pass SpriteBlendMode.AlphaBlend into the spritebatch.begin?

spriteBatch.Begin(SpriteBlendMode.AlphaBlend);

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.