Konaju Games

9Sep/111

Use The Right Tool For The Job

In the game I am currently working on, I was under the belief that I had no (or very few) memory allocations at run time.  And this was true for the most part.  The memory allocations that were still occurring were either from the .NET Framework or XNA on the PC (I’m looking at you, MouseMove messages) or allocations that we couldn’t track because they only happened on the phone and there is no equivalent to CLR Profiler on the phone yet.  What I didn’t count on was that many of the entities in a level were not being destroyed at the end of a level.

18Aug/117

Easy Asynchronous Content Loading

Asynchronous content loading is a technique employed by most of the larger XNA games to provide some animation or feedback during load times.  This is usually done by spawning a thread where content is loaded as normal.  If you want to load one or two assets in the background, then spawning a thread may be a bit of overkill.  Here I describe a simple ContentManager extension method that allows easy background loading for those small assets.

1Aug/112

Best Practices: Volume Controls, Not Sound On/Off

I love Windows Phone.  I think Microsoft have done a great job in developing a new user experience.  It is not all perfect though.  One area where it is up to the app developer to fill in some blanks is the area of audio control; specifically volume control.

30Jul/110

Enable SIMD support in Mango

We had all heard of the upcoming SIMD support in Mango and how it greatly improved the performance of XNA’s Vector and Matrix types.  What we didn’t know was that it is not enabled on your game by default.  Read on for how to get it enabled in your game.

26Jul/110

16-bit Textures with Dithering

As a general rule, I use DXT compression for textures applied to 3D objects but avoid it for anything that needs high quality and high contrast, such as user interfaces.  The default XNA texture processor offers the Color format, which is a full 32-bit BGRA pixel representation.  For devices that only use 16-bit back buffers, this is awfully wasteful of storage, memory and GPU bandwidth.  Also, the GPU is not smart about how it drops the pixel depth which can result in ugly banding on gradients.  A smarter choice will be to pre-process your textures into a suitable 16-bit pixel format with optional dithering to minimize banding, and we can make the content pipeline do the work for us.

21Jul/112

Thread-Safe Content Loading

As a general rule, the main or UI thread should never open, read or write any file.  File access is always so slow that it will stall the UI thread.  So most games will load their content on a background thread.  If content will only be loaded from one thread and you can guarantee that the content will only be loaded from one thread at any one time, then you are usually safe.  However, if there is a slight chance that two threads could try to load assets at the same time, you need to synchronize your loads.

19Jul/110

GraphicsDevice from ContentManager

Do you find that you sometimes need the game’s GraphicsDevice, but the Game instance is not easily available?  Do you have a ContentManager instance handy?  If so, you can easily get the GraphicsDevice from the ContentManager.