Tag Archives: Game development

The end of XNA?

If you are just starting with XNA game development, than you should probably read this post before you invest too much time in XNA.

Mind, this is no official statement from Microsoft, so there is still hope, but i agree with Promit. It is most likely, that we never see another big XNA update.


Read here: http://ventspace.wordpress.com/2011/11/28/directx-and-xna-status-report/

Chipset 915GV supports no PCIe Videocards

My videocard stopped working last week. So my first solution to this problem was to switch back to the onboard vga card. Problem with that is, that it cannot display the Windows Phone 7 emulator. So i cannot test or screenshot anything for the tutorial series.
I bought a new (cheap) PCIe videocard to solve this. Sadly it did not work and after some searching the web i found out, that my chipset, the old 915GV, does not support PCIe videocards. The only thing working in the PCIe slot is a special DVI Adapter extension for the onboard card.
What i am trying to say is, it might take a few days till i can update the tutorial again. Sorry about the delay.

Implementing a level of Detail (LoD) system in XNA games

If you have big levels and/or a huge amount of 3d models you have to render you will find that the game gets slower and slower.

Before you try to  optimize the draw codes, please use a profiler to make sure, that the problem is not somewhere else. Maybe the update logic is the problem?

You have some ways to tackle the problem:

  1. optimize everything in your draw code and shaders
  2. tell the user to buy a better computer
  3. remove objects
  4. lower the quality of models

Or you could scale the quality with the power of the computer displaying them.

To do so in a quick (and a bit dirty) way go to your class that holds the model and decides which model is to render (might be only one there without a LoD system or damage system).

  • Add a second and third model.
  • Make low poly versions of your model. One really low and one somewhere around the quality you can life with.
  • Load these lower versions of the model in your class
  • Add some code to check the distance to the camera
  • Now simply make some if statements:
    • If(distance >500.0f) do nothing
    • If(distance > 300.0f) draw(lowest_quality_model)
    • If(distance > 100.0f) draw(average_quality_model)
    • else draw (high_quality_model)
  • Play around till the numbers make sense in your game.
  • You might also add a condition that a slow running game never renders the highest_quality_model
  • As my LoD system not only draws the model but the shadows too i could use the lowest quality model to draw the shadow.
  • I also added a condition that the game fist tries to stop drawing shadows and than lowers the quality of models even further till the point where only the lowest poly models really close to the camera a drawn and the rest is ignored.
  • Be carefull with drastic measures. It is not always good to lower the overall quality of models just because the game missed one or two frames somewhere. The problem might not be the draw code at all.

Hope this helps you.

Workshop: Windows Phone 7 Game Development Lesson 3 coming up next week

We will display some 2D stuff and move it around.

How to Display Text in your XNA Windows Phone 7 game

First thing you need to do is add a SpriteFont object to your code.

Done like this: SpriteFont myFont (or whatever name you want to give it).

SpriteFont mySpriteFont

Add SpriteFont

Next you need an actual font you can load. For that you go to your solution explorer and right click your content project. Select add -> new item -> SpriteFont.

Add new item

Add SpriteFont to content project

Maybe you should select a better name, that the default one. But it doesn’t really matter much.

Select SpriteFont

Add SpriteFont

You can edit how your font looks like in the .spritefont file. It is a XML like format. Most stuff you find in there should be pretty much self-explanatory. At the bottom you find tags specifying a character region. Please note, that not all fonts can display all characters. If you happen onto a bug resulting from some character display problem or exception, have a look here, if your font can display all your characters. The rest describes size, text decoration and stuff.

spritefont file

The font description

For this post, I leave everything like it is and go on to actually displaying something on the phone.

First we need to load our SpriteFont1 in the ContentLoad()-method of our game class.

myFont = Content.Load("SpriteFont1")

All we have to do is display some text now.

We go to the Draw-method and beginn the spriteBatch draw with SpriteBatch.Begin().  The spriteBatch-Class offers us a DrawString-mehtod we use to display text. It first parameter is our SpriteFont. The secont the String you wish to display. This could of course come out of some Sting variable. The third is the position of the text on the screen and the last one, the color in the text is drawn in. We complete this with a spriteBatch.End() in the next line.

And see the result here: I made the Font bigger and red for this example. The size is controlled in the .spritefont file, the color can be selected in the DrawString-method.

Text on WP7 emulator

Building the best game development computer under $500

I spend the last days hunting down cpu benchmarks and conducting my own tests for a customer. The aim was to build a computer with the maximum power for compiling C# source code with only minimal costs.

As XNA Games are written in C# (at least in the most cases) i thought this would be something i would like to share with you.

Basics about building a XNA Game Solution in Visual Studio 2008

First a few things you need to know when building a XNA Game Solution in Visual Studio 2008. I know Visual Studio 2010 is out there buu the XNA support is still missing. Only XNA 4.0 and the windows phone development tools run in Visual Studio 2010 Express. I did not yet upgrade my project from XNA 3.1 to 4.0 so it was clear that i needed to use Visual Studio 2008. Back to the point. Things you need to consider when building XNA Game Solutions in Visual Studio 2008.

  1. The build process runs only on one core. Usually you have dependencies between the projects in a solution and they have to wait on each other to finish building before the next one can be build.
  2. The build process runs through different stages and different stages challenge different parts of your system.
  3. The build process might run for a long time and you might wish to work on something else why building.
  4. You are probably not buying a dedicated build system.

1. Builds run only on one core:

This lets me believe that clock speed is more important than many cores. I let the build of my project run on a i7 920 and the CPU load stayed constantly at 11 to 14% for the devenv.exe process. A quick calculation reveals that the i7 with 4 real cores and 4 virtual cores thanks to hyperthreading has a total of 8 cores. So a 100% cpu load means that every core is running under full steam. But if the process can only use one core, the overall cpu load should be around one eighth. 100% divided on 8 cores gives you 12.5%. I think the short peaks of 13+ can be attributed to some Visual Studio background processes and measuring inaccuracy.

So clock speed is really all that matters? Yes of course … wait … sadly no, it isn’t. While clock speed is a big factor in this, it is not the only one. You have to consider the processor architecture. While a Pentium 4 with 3.6 GHz is not a bad choice for building a i7 will still be faster. But not by much.

I let my project build on:

Intel® Core™ i7920 Processor (8M Cache, 2.66 GHz, 4.80 GT/s Intel® QPI) with 8 GB memory (DDR2) => 6 to 7 minutes (with a MySQL instance running but idle)

Intel® Pentium® 4 Processor supporting HT Technology 3.40 GHz, 512K Cache, 800 MHz FSB with 1.5 GB memory (DDR2) => 11 to 12 minutes

Intel® Core™ Duo Processor T2300 (2M Cache, 1.66 GHz, 667 MHz FSB)  with 3 GB memory (DDR2 Notebook) => 10 to 12 minutes

Intel® Pentium® D Processor 820 (2M Cache, 2.80 GHz, 800 MHz FSB) with 2 GB memory (DDR2) => 11 to 13 minutes

The order is more or less what i expected. I think with a memory upgrade to 2 GB the Pentium 4 could beat the Pentium D and the Core Duo T2300 by a minute or two. And this is what really suprised me. The Pentium 4 is as good, sometimes even faster, than it much newer brothers. Actually only the Pentium 4 used all the available memory at some point. Please consider that the test is not completely scientific. These are some computers i have access to. They do not run clean installtions. On some of them other services are running. I tried to get them as idle as possible but it isn’t a completly objective test. They do not even run the same Windows versions. The T2300 and the Pentium D are running Windows XP Professional, the rest Windows 7 Professional or Enterprise.

So this test is useless? If you are looking for scientific data, than yes, it is useless for you. But i still think it shows something quite suprising. The difference between a $40 computer (i bought the Pentium 4 used from a business next door that gave up for that sum) and a $1500 computer (the i7, new) is not factor 1000 like the price suggests.

Just out of curiosity i visited some webshops selling used computers. You can get a used workstation with a 64-bit Intel® Xeon® Processor 3.60 GHz, 2M Cache, 800 MHz FSB with 2 to 3GB ECC memory and a 160GB hdd for just $190 plus shipping. Sometimes even with 2 cpus or 4 to 8GB ECC memory for just a little bit extra power. These things are build to run forever so you have your perfect build server. Just put some the code changes via a repository on it and let it build one solution after the other.

2. Builds challenge different parts of your system:

To simplify this i will break the building process down in three parts:

  1. Getting data from drive.
  2. Compiling source code.
  3. Writing output to drive.

The ressource manager of Windows 7 shows the following for each step:

Getting data from drive:

  • CPU – mostly idle
  • Memory – working some
  • Harddisk – 100% load

Compiling source code:

  • CPU – 100% load. At least the one core used.
  • Memory – a nearly constant amound is used. In my case about 200MB. Not as much as i expected.
  • Harddisk – idle.

Writing output to drive:

  • CPU – mostly idle
  • Memory – working some
  • Harddisk – 100% load

So switching from a conversional harddisk drive to a ssd should give you a huge boost? Not really. I tried this with a SSD, a hybrid disk and a traditional hdd. Made next to no difference. The reason for this i quickly explained. Compared to the compile time the time spend reading and writing the data to the disk is so negligible that even a large performace boost in this area is not really noticeable.

So why do i read the advice to use a ssd for compiling so often? I don’t really know. I have a few theories about this. As we established above, the build process uses only one core, so when building in the background you should be bothered by it much… except for the few seconds large amounds of data are pushed from memory to disk. So what is the first thing you do? Look what ressources are taxed to the maximum by building you cool new awesome project. And suprise, you see the harddrive is the bottleneck. So of course you advice everybody to buy a ssd. Every reliable source told me the same. Visual Studio starts faster. The overall experience is faster, better, greater. But the build was running at the same speed as before. My own tests confirm this. A ssd ist great, but doesn’t help with build time. The hybrid disk is a cheap alternative and brings a slight boost but i in no way compareable to a ssd.

Please note that i am writing here about building a single XNA Game Solution in Visual Studio. There are of course cases where a fast harddisk is a huge speed boost.

3 + 4. You usually build in the background and do something else in the meantime if you have no dedicated build server / system.

What i want to tell you here ist, that it makes probably no sense to invest in a system you cannot use while building. For a dedicated build server it would be best to have one core (even hyperthreading is not really needed) with maximum speed, fast memory and a quick harddisk (or small ssd).

So our system should have at least decend power for stuff outside of coding games.

So what do i buy?

If you are one of those people who have their reserved parking lot at the local computer store, you can stop reading here. From here on i will focus on getting the best hardware for your money while staying under $500.

Let us start with the most important part, the CPU.

A quick glance at some benchmarks show us what a good cpu is for our problem. If you search for benchmarks on the internet be careful. Most benchmarks out there are for multithreaded applications. You need to look for ‘benchmark cpu single thread’. A good one is the ‘SPEC-Benchmark CPU2006‘ or the ‘Cinebench 11.5 (Singlethreaded)‘.

At the time i am writing this the winner in the category under $300 is the Intel® Core™ i5-2500K Processor (6M Cache, 3.30 GHz) already on the new socket 1155. It costs today $255. If you have a few dollars more to spend on this get the Intel® Core™ i7-2600K Processor (8M Cache, 3.40 GHz) for $365.

Of course you need mainboard. This is where the flamewar usually starts. A good, reliable, expensive one with a long list of features and great driver support for the next decade ist the way to go here …. wait what? … No! Get a cheap one. You might need a new one in a few years because it broke down or doesn’t support something or whatever. Who cares? You are building a $500 computer not a $15000 server here. Let me tell you a secret. If you spend the whole $500 on a fancy mainboard, even that won’t do much without a cpu, power supply and memory. So we are simply getting a nice $85 entry level mainboard. If you can get SATA\600 support for a little bit more, do it.

That brings us to memory. Memory is important. Really important. Really, really important. Okay, so you got that? Good. I think 4GB is a good compromise. There is a recogniseable difference between cheap and expensive memory. But we are on a tight budget, so get some cheap one from a manufactor that gives you at least a one year warranty. Should cost you about $45 (2 x 2GB DDR3 – 1333). If you have the money you can go for 4 x 2GB or 2 x 4GB whatever your mainboard supports. Should be about $85.

That leaves us with $115 for the case, power supply, a DVD drive and the harddisk. Wait! And the graphics card if you have none on your board. The graphics card is a problem. You are developing games on the computer. Games require good graphics cards. The point is moot. You cannot get a good gaming graphics card in $500 computer. A acceptable solution would be a nVidia GeForce GT 240 or GT 430. But they cost you an addition $100. If you want to use the computer for the newest blockbuster games in full hd and maximum details you need to spend $300+ on a GeForce GTX 560.

A case and powersupply are available for $60. Don’t get the cheapest stuff out there. Get the dealer to show you some quite ones with a good efficiency factor.

A DVD drive is $25.

The last decision would now be what hdd to buy. We have $35 left. I have seen the ‘500GB Western Digital 7200rpm 16MB Cache Serial ATA/600’ for $48.

Plus keyboard and mice ($8.50 each). Get something good. Logitech, Microsoft, Cherry. They have good sturdy devices. Just forego the multimedia keys and stuff.

Now the moment of truth. To be honest i di not add all the stuff up beforehand.


It’s $535. So you just have to get a 7% discount and we are under the promised $500. Agreed, it’s without a graphics card.

If you are not already on your way to the computer parts dealer of your trust, subscribe to my blog and have a nice weekend.

72 hours weekend challenge at gamedev.net

You have a free weekend and a great game idea?

If you know some programming and want some fun developing a game, than paticipate here.

Prices to win!

New GameDev.net Challenge!

Update: Theme is announced

In the immortal words of MC Hammer, “U Can’t Touch This”. Take it literally, figuratively, or sideways

%d bloggers like this: