Box2d for Qt 4.7



  • I have downloaded Box2d v2.1.2. And I was able to compile it & run the examples in it using Visual Studio 2008. Now how can i use the library & header files of the Box2d to my current project. HOw can I use the library of Box2d for Qt. Go i have to install it separately for Qt??



  • This is a bit off topic, as it's not related to Qt as such, but a general configuration problem.

    What to do depends on the library and should be described in the docs of your Box2d library. Some libs can be used out of the source tree, some want to be installed.

    To add the lib to your project, just follow the "Declaring Other Libraries":http://doc.qt.nokia.com/4.7/qmake-project-files.html#declaring-other-libraries documentation of qmake.

    Alternatively, you can add the include and lib paths and the libraries to the Visual Studio project directly (but be aware that this will be overridden once you recreate the project file from a .pro file with qmake).



  • Integrating Box2D is pretty simple. There was a Qt Labs post about it awhile ago. I was also able to integrate it into my game engine. It's works very well. The one thing to watch out for is the differences in scale. Box2D works will with things on the order of 10 units. If you match one Box2D unit to one pixel, you won't have very good results. So what I did was apply a constant scale factor when converting from Qt/pixel coordinates to Box2D coordinates.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.