Box2D C++ tutorials - Setting up (Linux)Last edited: July 14 2013
Building the testbed (Linux)
Let's look at the process of setting up the default 'testbed' which is part of the Box2d source code base. The testbed is a very useful tool which contains examples of various features which you can interact with using the mouse, adjust parameters, pause and step the simulation etc.
Here I am using a fresh install of Fedora 14, so I might as well start right from the very beginning.
The simplest way to build the Box2D library is to use the cmake file which is included in the source code download. To do this you will need the cmake tool, and obviously a c++ compiler. For the testbed you will also need the developer libraries for GLUT and an input library for X windows. You can use yum to install all these in one go, like this:
yum install gcc-c++ cmake freeglut-devel libXi-devel (Ubuntu) sudo apt-get install g++ cmake libglu-dev libxi-devDownload the Box2D source code archive from here. If you want to use the terminal all the way, you could also do this (if wget is not available, use yum to install it):
wget http://box2d.googlecode.com/files/Box2D_v2.1.2.zipUse the following commands to unzip and build it.
(Update: See also david's comment below for Ubuntu
unzip Box2D_v2.1.2.zipAfter this you should see that some new folders have been created, one of which is 'Testbed' and this in turn contains an executable file called 'Testbed', so the app can be started like this:
cd TestbedYou should see the testbed window showing like this:
Select from the drop-down list in the top right to try out the tests that are currently in the testbed. We will be adding our own items into this list later on.
Apart from the obvious features visible in the right hand control panel, the testbed also allows you to:
- Move the view around - arrow keys or drag with right mouse button
- Zoom the view - z,x keys
- Grab objects in the scene - left mouse button
- Launch a bomb into the scene from a random location - space bar
- Launch a bullet into the scene - drag left mouse button while holding shift, then let go
Next: Testbed structure