Installing Visual C++ 2005 Express

Notice

This article is outdated!
Instead of following the steps in this article, just download and install the newer Visual C++ Express editions which already include the Windows SDK (previously known as the Platform SDK).

This article will explain how you can install the freely available Visual C++ 2005 Express Edition together with the Windows SDK required to create Windows applications and use most of the code available on the ‘net.

If you’re interested in doing Windows game development in C++, Visual C++ 2005 Express is a great choice because it combines a world class IDE with the optimizing version of the Microsoft C/C++ Compiler. If you’re concerned with standards compliance, rest assured that Microsoft’s compiler is among the best.

More Information

History Lesson: Microsoft and the C++ Standard

The idea that Microsoft compilers have poor standards compliance is rooted in Visual C++ 6.0, which was shipped before the C++ ’98 Standard had been completed but lived well into the C++ ’98 era. Visual C++ 2005 doesn’t have such problems at all and is actually one of the best – if not the best – compiler in terms of ISO/ANSI C++ standards compliance. With Herb Sutter, Microsoft has also won a famous member of the C++ standards committee for its own development team (see ISO/ANSI C++ Standards Committee Secretary Herb Sutter Joins Microsoft’s Developer Division).

The only obstacle for game programmers is that the Express Edition of Visual C++ 2005 doesn’t include the Platform SDK, Microsoft’s collection of headers and libraries for windows development, including the all-time famous Windows.h. This article will guide you through the entire process of installing Visual C++ 2005 Express, setting up the Platform SDK and configuring your build environment.

Read More

XNA Windows.Forms UserControl

Notice

This article is outdated!
This was a pretty cool achievement at the time, but XNA 1.0 is long gone. Microsoft now offers their own examples on how to do this:
WinForms Series 1: Graphics Device
WinForms Series 2: Content Loading

A topic that pops up every now and then is how to use XNA in a Windows.Forms application. This is rather difficult because the GraphicsDeviceManager provided by Microsoft creates its own window and will not cooperate with a normal Windows.Forms window, thus forcing the developer to roll his own GraphicsDevice initialization and management code (which is quite a bit of work!)

As can be seen in one of my recent news posts, I did just that while developing a world editor for my upcoming game Island War. Because of the great demand for such a component, I decided to release my XNA GameControl class to the public. You can download it here:

An XNA-based pong clone running inside a Windows.Forms application

How to use:

  1. Add a reference to Nuclex.GameControl.dll (or to the project if you integrated the project file into your solution)
  2. Create a new UserControl that inherits from Nuclex.GameControl. You can do this by adding a normal UserControl and replacing the : UserControl by : Nuclex.GameControl in the class definition.
  3. Override the LoadGraphicsContent(), UnloadGraphicsContent(), Update(), Draw() and so on methods as usual.

There’s one issue: Because the working directory will be set to the system’s temp folder when your control is shown in designer mode, you will not be able to view your game in the Visual Studio Forms Designer if it is loading content using the XNA content pipeline (well, unless you want to copy your project’s output folder into your temp directory whole). There will be no problems starting or debugging the project, though.