Aligning an SSD on Linux

I’ve got a small home server with a software RAID-5 for storing my files. It also runs a few virtual machines and acts as a NAT router for internet access. Nothing expensive, just some Frankensteinian patchwork built from old hardware left over when I upgraded my workstation. Nevertheless, I granted it a brand new Intel X25-M SSD last week.

Photo of an Intel X25-M SSD drive, which is a metal box smaller than a CD case

Did I mention that this server is running Gentoo Linux? I thought this would be a good time to do a fresh install and get everything right that might have gone wrong the first time. Besides, installing Linux always is an interesting (and masochistic) experience, especially when your chosen distribution has no installer :)

Because getting my partitions and file systems aligned also proved to be difficult task, I thought why not make a small article out of this!

Read More

Game Architecture Series

Stylish logo of two engaged gears with the text XNA Game Architecture

Series

I’m planning to start a short article series:

There are a lot of XNA tutorials out there that explain the basics – how to display a sprite, how to do collision detection and how to render a bunch of colorful particles with additive blending. But there aren’t many articles that explain to you how you’re supposed to put it all together – how to structure a game so that it is easy to extend and remains manageable when the amount of code begins to grow.

The discipline that deals with this issue is called software architecture. Like programming, or any other creative process, it relies a lot on tacit knowledge – finding a good solution without first running down an alley of dead ends (that you can identify using the Principles of Object-Oriented Design) requires a lot of experience.

What I will do in this series is let you look over my shoulder as I design a small game and try to explain my motivations for choosing one design over another while I do so. This will give you a solid starting point and an understanding of the design process that you can apply to your own game projects.

The Meaning of 100% Test Coverage

When I release components, example code or even just helper classes, I often tout 100% test coverage as a feature. Which (as I probably also state often enough :P), means that my unit tests execute 100% of all lines in the source code. But what advantage does this actually bring to a developer, and, just as interesting, what does having complete test coverage not mean?

For people practicing true TDD (test first -> red, green, refactor), 100% coverage is nothing unusual, though even they may decide to not write tests for all invalid inputs possible: if a piece of code satisfies all the tests and the tests cover everything the code should do, it’s enough. If you’re building a library on the other side, the use case of a customer providing invalid inputs will be a valid concern worthy of a test.

I, however, am currently adding unit tests to an existing code base and I decided to go for 100% test coverage. In this short article, I will explain why I see complete test coverage as a worthwhile goal, what effect going for that level of test coverage has on a project and what it says about the code.

Read More
Logo of the Nuclex Framework, the text "Nuclex" with three green dots on a blue ring

Nuclex Framework R984 Released!

The word 'Nuclex' with a stylish font framed by an elliptical ring with three dots

I just uploaded a new release of the Nuclex Framework on CodePlex!

It has been a lot of work getting the GUI library finalized. For once, I really wanted to have 100% unit test coverage on the whole library, which meant a lot of work ensuring the design allowed for this and thinking of all the test cases. But hey, what other GUI library can provide that level of unit tests! :)

Another feature I didn’t want to let go of was control navigation with the game pad and cursor keys. The idea is that you, the developer, just throw some controls on the screen and the GUI will automatically figure out which control to change focus to when the player uses the thumb stick on his game pad. This means you can just add four buttons labeled “New Game”, “Options”, “Credits” and “Quit” to your screen and voilà, you’ve got a main menu the user can interact with using his mouse, keyboard or game pad.

Read More
The logo of the WiX XNA intaller, a cheap montage of the WiX and XNA logos

WiX XNA Installer 3.1

WiX XNA Installer Logo

I just uploaded a new release of my WiX XNA Installer template that has been updated to XNA 3.1!

If you happen to have a customized installer built on the XNA 3.0 template, fear not, for the required changes are very small! Use your favorite Diff/Merge tool and copy over any changes referring to Xna_3_1 into your existing installer.

I have declared this release a beta because I haven’t gotten around to testing it on all possible operating systems.

A Look Back: Gothic 1

In just two days, “Risen” will be on the store shelves. Risen is the inofficial child to the excellent Gothic series, a trilogy of role-playing games produced by german developer Piranha Bytes.

Because of this special opportunity, allow me to revel in ancient times and take a look back at the series’ previous games. I have played all parts so far, including all add-ons, with the exception of the publisher’s cannibalization attempt that is “Forsaken Gods” (which means I played exactly one Add-On, “Night of the Raven” :P).

In my opinion, no other game can compare to this series, no Elder Scrolls, no Baldur’s Gate and no Fallout. Read on to find out why I’m so addicted to the Gothic series :)

Scan of the Gothic 1 package cover

Read More
Logo of the Nuclex Framework, the text "Nuclex" with three green dots on a blue ring

Nuclex Framework on CodePlex

The Nuclex Framework has been released to CodePlex today!

The word 'Nuclex' with a stylish font framed by an elliptical ring with three dots

Instead of only writing about all the cool stuff and then pointing people at my Subversion repository whenever someone asks for the source code, I finally sat down and published the entire Nuclex Framework on CodePlex, together with lots of examples, documentation and screen shots.

The Nuclex Framework consists of small isolated building blocks that you can pick from, so you can easily use just the things you require and ignore the rest (or even create your own trimmed-down edition of the framework if you’re not worried about doing it all again when a new version is out).

All the highlights I wrote about in this blog (and quite a lot that I didn’t write about) are neatly organized in there. And the code’s quality should hopefully speak for itself :)

Just to list some of the more interesting things, there’s a Deque collection (faster than List<> and LinkedList<> and much less garbage), 3D vector font rendering code, 7-Zip content compression, a 3D SpriteBatch equivalent, rectangle packing algorithms for texture atlas creation, a flexible multi-threaded particle system, a work-in-progress GUI library with skin support, a cleaner game state management system, a debug overlay renderer and some helpers that allow you to automatically create VertexDeclarations from a structure without listing the VertexElements by hand.

So what are you waiting for, check it out! :D

Efficiently Rendering Dynamic Vertices

Sometimes, games have to render highly dynamic geometry such as sparks, bullet trails, muzzle flashes and lightning arcs. Sometimes it’s possible to off-load the work of simulating these things to the GPU, but there are effects than can’t be done by the GPU alone.

These cases usually occur when effects require heavy interaction with level geometry or when they require lots of conditionals to mutate a persistent effect state. And sometimes, the effort of simulating an effect on the GPU is just not worth the results. If you have maybe a hundred instances of a bullet trail at once, letting the GPU orient the constrained billboards for the trails instead of generating the vertices on the CPU might just not yield any tangible benefits.

However, there are still a lot of traps you can run into. A typical mistake of the unknowing developer is to render the primitives one-by-one either using one Draw[Indexed]UserPrimitives() call per spark/trail/arc.

This is not a good idea because modern GPUs are optimized for rendering large numbers of polygons at once. When you call Draw[Indexed]UserPrimitives(), XNA will call into Direct3D, which will cause a call into driver (which means a call from code running in user mode to code running in kernel mode, which is especially slow). Then the vertices are added to the GPU’s processing queue.

By sending single primitives to the GPU, this per-call overhead is multiplied and can become a real bottleneck. To demonstrate the effects of making lots of small drawing calls, I wrote a small benchmark and measured the results on my GeForce 8800 GTS 512 and on whatever the XBox 360 uses as its GPU.

Chart showing a drastic performance bottleneck for excessive DrawPrimitive() calls

Read More

Best Video Games of this Decade

This is my personal list of must-play games in the post-2000 era. I find that often, my opinions differ greatly from the reviews in gaming magazines. For example, I liked DooM 3 because of its story, which I find immersive and fascinating, whereas most people regard the game as a tech demo for id’s engine. And I totally don’t get Call of Duty 4/5, the story (?) was uninteresting and has you incoherently jumping from place to place with scripted annoyance everywhere that prevents you from playing in your own style :)

If you’re equally weird, maybe you can find one or the other insider’s tip within this list to check out :D

The game's box showing the hero standing in a white light being held by two claw-like hands

Read More