T2D/TGBTutorials/BuildingADebugVersion

From TDN

Contents

Building a Debug Version of Torque Game Builder with Microsoft Visual C++ 2005 Express Edition

 

Jason "TGB Boy" Cahill

February 24, 2006

 

This article will help you create a debug build of TGB. Learning how to build your own version of TGB from the source code is important for several reasons:

  1. You can make changes to the source code. This will allow you to create or modify various aspects of the engine, including implementing new features provided by other community members.
  2. You can run multiple instances of TGB on the same computer (which is necessary for building and testing multiplayer games).
  3. You can debug the game engine when you find bugs or crashes.

The bottom line is, you need to know how to build if you want to do anything more than write 100% script-driven games. Knowledge is power, and this article will help you through the 5 easy steps to create your own compiled version of TGB.

Step 1: Prepare your development environment

If you haven't already done so, please follow all of the instructions provided in our previous article, entitled Setting up a Microsoft Windows®-based development system for Torque Game Builder.

Step 2: Boot Visual C++ Express Edition

Click on Start, then All Programs, then Visual C++ 2005 Express Edition, and then Microsoft Visual C++ 2005 Express Edition.

 

Image:TGB002-01-shell-start_menu.jpg

 

And, after a few seconds you should see:

 

Image:TGB002-02-vc-boot.jpg

­Step 3: Open the Solution

The next step is to open the TGB “solution.” What is a solution, you ask?

Well, in Visual C++ parlance, all of the projects, source code, resources, and settings necessary to create compiled software are bundled up into a file called a solution. A single solution can contain multiple projects, each of which can contain multiple files of source code. A single project always results in exactly one compiled piece of software. The output of a C++ project is generally one of the following kinds of files:

  • A .lib file, which is a reusable library of code that can be linked into other projects to build an .exe.
  • A .dll file, which is a dynamically loaded library of code used by an exe.
  • Or, an .exe file, which is a Windows executable.

 

When we build the TGB solution, it will compile over 600 source code files and result in four output files:

  • opengl2d3d_DEBUG.dll – this file allows TGB to create output using Direct3D. Internally, Torque Game Builder is all written using OpenGL for graphics. This dll is responsible for mapping all of the OpenGL calls into the equivalent Direct3D calls. Supporting both graphics APIs can provide for a wider range of compatibility with your target customer’s computer systems.
  • glu2d3d_DEBUG.dll – like the file above, this library maps another subset of OpenGL, specifically the GL Utility library to Direct3D.
  • T2D_DEBUG.exe – this is the debug version of TGB.
  • T2D_DEBUG.ilk – this file is a by product of compiling. It is an “incremental link file” and is used to speed up successive builds that you create to TGB.

 

To get started, click on the File menu, then click on Open, then click on Project/Solution.

 

Image:TGB002-03-vc-open_solution.jpg

 

This will launch the Open dialog:

 

Image:TGB002-04-vc-open_dialog.jpg

 

In the File name: edit box, type C:\TGB\Latest and press the Enter key. This will jump start you to where we installed the latest build of TGB. Double-click on the engine folder, then double-click on the compilers folder, then double-click on the VisualStudio 2005 folder, and then, finally, double-click the T2D SDK.sln file.

In a few seconds, Visual C++ should load all of the projects, files, and settings, and you should see the following screen:

 

Image:TGB002-05-vc-solution_opened.jpg

Step 4: Build the Solution

Before we kick off the build, notice a couple of quick things about Visual C++. First, you should see a Task Pane entitled Solution Explorer – T2D. Notice that it contains a solution T2D SDK and seven projects. These projects contain all of the source code that make up TGB. In future articles, we will explore these projects in more depth, but for now, just take note that they exist.

The other thing to notice is a drop down control on the main toolbar that says Debug. This is the current configuration that Visual C++ will build. If you click on the drop down arrow, you will see that there are two possible settings: Debug and Release. For now, let’s leave this set to Debug. If at some point later, however, you would like to build an optimized release build, this is where you would select this setting.

OK, let’s kick off the build! Click on the Build menu, then click on Rebuild Solution.

 

Image:TGB002-06-vc-rebuild_all.jpg

 

Because this is the very first time we are compiling TGB, we are selecting this option to ensure that Visual C++ creates a complete, clean build. After this build is complete, if you decide to make changes to the engine source code, you simply need to select Build Solution, which will only compile the changes since you last built. This minimal rebuild will be much faster for subsequent builds.

By now, Visual C++ should be cranking away, compiling each of the source code files. As I mentioned earlier, there are over 600 files in TGB, so this will take a few minutes depending on the speed of your system. When you are all done, you should see this:

 

Image:TGB002-07-vc-build_completed.jpg

 

In particular, notice that the Output Task Pane contains the text:

********** Rebuild All: 7 succeeded, 0 failed, 0 skipped **********

If you do not see this, for example, if you see any errors, then it’s most likely that your configuration has not been set up perfectly. Please refer back to the article listed in Step 1 and ensure that you carefully followed each step.

Step 5: Let the Games Begin!

Guess what? We are done with Visual C++ for this article. You did it! Give yourself a big pat on the back. Now it's time to see what we built and to try it out! You can close Visual C++ at this time.

Click on Start, then click on My Computer. Next, double-click on Local Disk (C:). If you see the following screen:

 

Image:TGB002-08-shell-hidden_files.jpg

 

Click on the link entitled Show the contents of this folder. You should now see something like:

 

Image:TGB002-09-shell-c_drive.jpg

 

Double-click on the TGB folder, then double-click on the Latest folder, then double-click on the games folder. You should now see something like this:

 

Image:TGB002-10-shell-games.jpg

 

Notice that the four new files we discussed earlier (opengl2d3d_DEBUG.dll, glu2d3d_DEBUG.dll, T2D_DEBUG.exe, and T2D_DEBUG.ilk) are here. Double-click on the T2D_DEBUG.exe file. You should now be running the debug version of TGB:

 

Image:TGB002-11-TGB-debug.jpg

 

Debug builds are much slower than release builds, but other than being achoppier performance-wise, you shouldn’t notice any functionality differences between the debug build and the release build. Congratulations once again, you now know how to build your own version of TGB!