Simple tutorial using graphics

ah, no, its ok, I fixed it. I hadn't realised that the groundBody had no collision. However, I do have another question now;

I realise that b2bodys have to have polygon(s) associated with them to collide, and I know how to get the vertices of that polygon. However, when the body is updated how do I then get the vertices of the shape associated with the body. this may be unclear or impossible.

for example, say I had a body, with a polygon set as a box. now I know how to get the vertices of that shape, and I have managed to create a simple hack by adding the bodys coordinates to each of the vertices and this is ok, if the shape does not rotate. however, if it rotates the vertices do not, and I was wondering if there was a way of getting the locations of the vertices of the shape each "frame" even if the body is moving or rotating. Ill post my sample code to show you what Ive done so far (rubbish as it may be).
Normally, you shouldn't be using the vertices from the bodies to draw. You should be using the transformation information to update your graphical objects. If you really want to display the shape information from Box2D, then you need to implement the b2DebugDraw interface. Check the test bed for code examples using glut.
could you give an example please, as i don't really understand what you mean... sorry!

ps.
I have looked through the testbed, and that's where i got much of my drawing code from...
If you want an example for the b2DebugDraw interface, then the test bed should be a pretty good example.

If you want an example for updating the graphical objects, like I said, I don't know glut or opengl, so I can't provide an example. You'll most likely need to build a transformation matrix and use that when you render your objects. There should be plenty of examples around the web.

If you're serious about making something more functional than the test bed(aka nice graphics which are not lines), then reread my first post in this thread.
I suggest you first write an OpenGL program that moves a box around the screen. Don't use Box2D at all. Express the position of the box as position and rotation. Call this box your "actor". You should try to put a texture on your actor. Actually go ahead and create an actor class similar to this:

Code:
class Actor
{
  void Draw();

  float x, y;
  float angle;
}

Add to it whatever you need to get the job done. Implement the Draw function to use x, y, and angle to draw your box using OpenGL commands.


Next you can hook up Box2D. Create a similar box on a rigid body. Step the simulation and use the position and rotation of the body to move your actor.

Code:
class Actor
{
  void Draw();
  void Update();

  b2Body* body;
  float x, y;
  float angle;
}


After stepping b2World, call Update. This just copies the body position and rotation into x, y, and angle. Then call your old Draw function.
Thank to all of you, youve all been really helpful. Im trying to create a vector based box2d thing, so im going to try and create some functions (like the debugdraw) to simply draw simple shapes for the bodys. Im not really interested (at the moment) in creating anything using complicated graphics or bitmaps.

but thanks anyway for all of your imput its been really helpful

Original thread: https://box2d.org/forum/viewtopic.php?t=3257