Thanks for the tip, this is exactly what I needed. So, I'm at the point where it's compiling, but it doesn't draw the debug data. I compared my code to the testbed, and honestly I can't find anywhere in the testbed files where m_debugData (or b2Draw class, technically) is instantiated.
I checked the b2World.cpp file, and it looks like I am setting a null b2Draw object to the world.
Code:
void b2World::DrawDebugData()
{
if (m_debugDraw == NULL)
{
return;
}
// ...
Mine just returns at that point. I put a break at the same point in the testbed file, and it passes the null test just fine; but like I say, I cant see where that object is being instantiated, or how because it is an abstract class isn't it?
Here is the relevant code in "Game.mm":
Code:
// Game.mm - init
- (void) init {
. . .
// Debug Draw functions
DebugDraw d;
world->SetDebugDraw(&d);
uint32 flags = 0;
flags += DebugDraw::e_shapeBit;
flags += DebugDraw::e_jointBit;
flags += DebugDraw::e_aabbBit;
flags += DebugDraw::e_pairBit;
flags += DebugDraw::e_centerOfMassBit;
d.SetFlags(flags);
. . .
}
// Game.h
#import "cocos2d.h"
#import "Box2D.h"
#import "Render.h"
#import "Globals.h"
#import "MyContactListener.h"
#import "Points.h"
#import "UI.h"
#import "Items.h"
#import "Matrix.h"
#import "VirusOrbit.h"
@class UI;
@class Items;
@interface Game : CCLayer
{
b2World* world;
DebugDraw m_debugDraw;
. . .
}
. . .
void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color);
void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color);
void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color);
void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color);
void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color);
void DrawTransform(const b2Transform& xf);
void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color);
void DrawString(int x, int y, const char* string, ...);
void DrawAABB(b2AABB* aabb, const b2Color& color);
@end