Archive, XNA

Multithreading for the Xbox 360

Jason / January 27, 2007

When multithreading on the Xbox 360, here are a few things to keep in mind.

Affinity
In multithreaded programming, programmers often lack the ability to specify the Processor Affinity of a thread. Even when API calls are available to specify a processor, it is usually ignored. The reason for this is that modern operating systems have many processes running, each with many threads. The operating system zealously manages processor affinity in order to maximum some metric. read more

Archive, C#, XNA

Embedding Assets Into Your XNA Game

Jason / January 21, 2007

Currently I am a working on a small XNA project whose solution is composed of 4 projects, a DLL, a Windows Game, a Xbox 360 game, and a level editor. Each projects needs access to my assets (currently just 2d sprites), and has raised the interesting question of how to easily share them between each project.

What I had been doing was adding the assets to the Windows game as pipeline content. After compiling it I would then copy the compiled assets from the bin directory, to the bin directories of the level editor and the Xbox 360 game. While this worked, it was error prone and time consuming.

Instead I found that I can add my assets to the DLL as embedded content, and then load them at runtime. Normally you would have probably loaded content by calling the "Load" method of "ContentManager", like:

            _content.Load<Texture2D>("mySprite");

As stated above, the problem with this solution is that "mySprite" would have had to been compiled into the content pipeline. When your assets are added as embedded content, the above method does not work. Instead, you can load your content like this:

Assembly asm = Assembly.GetExecutingAssembly();
Texture2D.FromFile(_graphicsDevice, asm.GetManifestResourceStream("SampleProject.Textures.mySprite.png"));
read more