Box2D v2.3.1 loader

General discussion about the R.U.B.E editor
Post Reply
jcollier
Posts: 3
Joined: Tue Feb 24, 2015 4:51 am

Box2D v2.3.1 loader

Post by jcollier »

I recently downloaded Box2D v2.3.1 from box2d.org. They completely rebuilt the Testbed to use GLFW insteaad of freeglut. I was able to take the Box2d testbed (C++) sample loader, and move over the 3 loadrube test (along with the rubestuff b2dJson files). After updateing m_debugDraw references to the new g_debugDraw, the RUBE scenes work great.

That is, all except the images/textures. They load into the window, but are scaled to large, and do not pan or zoom with the camera. Unfortunately, I am new to c++ and openGL, and cannot seem to figure it out.

Do you have any plans for a v2.3.1 c++ testbed loader?
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Box2D v2.3.1 loader

Post by iforce2d »

No. Apart from the testbed, very little seems to have changed in the engine itself. I did spend significant number of hours trying to get the new testbed running and eventually gave up due to annoying issues on Linux, and also becuse the payoff is quite small. That is to say, even if I got it working, all I would have is a testbed that worked just the same as before. The testbed is not actually an end goal to be used as a game engine/framework anyway, and the player view in RUBE lets you do everything the testbed does and has more detailed display of joints etc.
jcollier
Posts: 3
Joined: Tue Feb 24, 2015 4:51 am

Re: Box2D v2.3.1 loader

Post by jcollier »

Completely understandable. I had to upgrade to Glew 1.12.0 and fix the path to DroidSans.ttf before I could ever get it to build successfully on mine, but I am using windows w/ codeblocks.

This had just turned into more of a personal challenge for me, than a practical need. I will keep playing with it and post back if I find a solution.
jcollier
Posts: 3
Joined: Tue Feb 24, 2015 4:51 am

Re: Box2D v2.3.1 loader

Post by jcollier »

I finally got it to work, but it took a lot of frustration and me learning a few things.

In case you ever come back to this in the future, Box2D v2.3.1 uses OpenGL 4.0, complete with vertex & fragment shaders. Because it also uses a camera and projection matrix, I had to update the b2dJsonImage_OpenGL.cpp to also use shaders. glTranslatef and glRotatef don't seem to work this way, so I wrote a new function inside DebugDraw.cpp to render the images, bind them to the VBO, and pass in the vertex and texture coord info.

This probably isn't the most elegant way, since I had to modify the testbed source to get it to work, but I am pleased. The Json exports from RUBE seem to be loading perfectly now.
Post Reply