Skip to content
Openframework wrapper for box2d
Branch: master
Clone or download
Latest commit 049d9db Dec 27, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
example-Bodies Update main files. Feb 12, 2017
example-ComplexPolygon Clean up whitespace. Feb 12, 2017
example-ContactListener Update main files. Feb 12, 2017
example-CustomData Update main files. Feb 12, 2017
example-Edges Clean up whitespace. Feb 12, 2017
example-Forces Update main files. Feb 12, 2017
example-Joint Update main files. Feb 12, 2017
example-Performance Clean up whitespace. Feb 12, 2017
example-Simple Update main files. Feb 12, 2017
example-TwoWorlds Clean up whitespace. Feb 12, 2017
example-iOS Clean up whitespace. Feb 12, 2017
libs merged, removed static_assert Apr 12, 2015
src Fix GLM / ofPolyline-related vector problems. Feb 12, 2017
.gitignore reorganzied/renamed folder structure to follow ofxAddonTemplate, ofxB… Aug 12, 2012
License.txt Required License and Updated Readme Jul 10, 2013 Update Dec 27, 2017 don't need explicit ios libs include Apr 5, 2016
ofxaddons_thumbnail.png added (temporary) thumbnail for upcoming v2 Aug 12, 2013




This is a simple wrapper for Box2d using Openframeworks. The examples below are still in progress, but should be stable for the most part. Please open up a issue if you have suggestions or find bugs. The wrapper is using Box2d version 2.3.

Thanks, Todd


First, pick the branch that matches your version of openFrameworks:


When making a vector of objects you need to be careful. You either need to make a vector of pointers or use the shared_ptr object.

Everytime you push into the vector circles the object is destroyed and the created. This causing issues for the b2dBody body object owned by Box2d.

Incorrect way to store objects.

vector <ofxBox2dCircle> circles;
ofxBox2dCircle circle;

Here is the how to create a vector of Box2d objects.

// in your header files
vector <shared_ptr<ofxBox2dCircle> > circles;

// now add a circle to the vector
auto circle = std::make_shared<ofxBox2dCircle>();

// to grab the pointer you use the get() function of shared_ptr (std::shared_ptr)
circle.get()->setPhysics(3.0, 0.53, 0.1);
circle.get()->setup(box2d.getWorld(), 100, 100, 10);


Place ofxBox2d within a folder in the apps folder of the OF dir tree:



The master branch is compatible with the current release of openFrameworks, and the develop branch tries to stay up to date with openFrameworks on GitHub.

You can’t perform that action at this time.