Monthly Archives: September 2009

Foreach through non-primitive types creates garbage.

Time and again I have seen code like this used in XNA tutorials. effectDrawBlock.Begin(); foreach (EffectPass pass in effectDrawBlock.CurrentTechnique.Passes) { pass.Begin(); gd.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, 35, 0, 70); pass.End(); } effectDrawBlock.End(); When you use a foreach over an array of ints … Continue reading

Posted in Coding, XNA | Tagged , | 4 Comments

ToString Garbage Creation in C#

I profiled my XNA game project today using the XNA Framework Remote Perf Monitor and discovered that I was generating about 8000 more manage objects per second than I was expecting to. It turns out that this code was generating … Continue reading

Posted in Coding, XNA | Tagged , , | 4 Comments

Convert greyscale images to Alpha8 format with a Custom Content Processor in XNA 3.1.

I noticed that at least two terrain engine examples in XNA are reading heightmap images into 4 channel textures instead of single channel textures. To create a custom content processor that will permit you to convert any Texture2D compatible input … Continue reading

Posted in Coding, XNA | Tagged , , , | 2 Comments