HI
My DebugDraw doesn't seem to be working. The code doesn't seem to be accessing any of the functions at all (I know cause I've put cout statements in all of them). I added it to the World using the SetDebugDraw function and I even checked the framework I seem to be doing the same thing !!
I'm using Ubuntu 8.10 and Box2D ver 2.01 (cmake-build).
Here is the code in case anyone is Interested -
If someone is feeling really benevolent maybe they could add the code to a blank project on their system and try it out ? (I'm using SDL along with SDL_gfx )
🙂
My DebugDraw doesn't seem to be working. The code doesn't seem to be accessing any of the functions at all (I know cause I've put cout statements in all of them). I added it to the World using the SetDebugDraw function and I even checked the framework I seem to be doing the same thing !!
I'm using Ubuntu 8.10 and Box2D ver 2.01 (cmake-build).
Here is the code in case anyone is Interested -
Code:
#ifndef DEBUGDRAW_H
#define DEBUGDRAW_H
#include <Box2D/Box2D.h>
#include <SDL/SDL_gfxPrimitives.h>
class DebugDraw : public b2DebugDraw
{
public:
DebugDraw();
virtual ~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 ¢er, float32 radius, const b2Color &color);
void DrawSolidCircle (const b2Vec2 ¢er, float32 radius, const b2Vec2 &axis, const b2Color &color);
void DrawSegment (const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color);
void DrawXForm (const b2XForm &xf);
protected:
private:
};
#endif // DEBUGDRAW_H
#define DEBUGDRAW_H
#include <Box2D/Box2D.h>
#include <SDL/SDL_gfxPrimitives.h>
class DebugDraw : public b2DebugDraw
{
public:
DebugDraw();
virtual ~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 ¢er, float32 radius, const b2Color &color);
void DrawSolidCircle (const b2Vec2 ¢er, float32 radius, const b2Vec2 &axis, const b2Color &color);
void DrawSegment (const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color);
void DrawXForm (const b2XForm &xf);
protected:
private:
};
#endif // DEBUGDRAW_H
Code:
#include "DebugDraw.h"
#include <iostream>
DebugDraw::DebugDraw()
{
//ctor
std::cout << "Constructor - DebugDraw" << std::endl;
}
DebugDraw::~DebugDraw()
{
//dtor
}
void DebugDraw::DrawPolygon (const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)
{
SDL_Surface * screen = SDL_GetVideoSurface();
for(int i=0; i < vertexCount-1; i++)
{
lineRGBA( screen, vertices[i].x, vertices[i+1].x, vertices[i].y, vertices[i+1].y,
0, 255, 0, 255 );
}
lineRGBA( screen, vertices[vertexCount-1].x, vertices[0].x,
vertices[vertexCount-1].y, vertices[0].y,
0, 255, 0, 255 );
std::cout << "Drew Polygon" << std::endl;
}
void DebugDraw::DrawSolidPolygon (const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)
{
DrawPolygon( vertices, vertexCount, color);
std::cout << "Drew Solid Polygon" << std::endl;
}
void DebugDraw::DrawSegment (const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color)
{
std::cout << "Drawing Segment" << std::endl;
lineRGBA( SDL_GetVideoSurface(), p1.x, p2.x, p1.y, p2.y, 0, 0, 255, 255);
}
void DebugDraw::DrawCircle (const b2Vec2 ¢er, float32 radius, const b2Color &color)
{
circleRGBA( SDL_GetVideoSurface(), center.x, center.y, radius, 0, 255, 255, 255);
std::cout << "Drawing Solid Circle" << std::endl;
}
void DebugDraw::DrawSolidCircle (const b2Vec2 ¢er, float32 radius, const b2Vec2 &axis,const b2Color &color)
{
circleRGBA( SDL_GetVideoSurface(), center.x, center.y, radius, 0, 255, 255, 255);
}
void DebugDraw::DrawXForm (const b2XForm &xf)
{
std::cout << "Drawing XForm" << std::endl;
}
#include <iostream>
DebugDraw::DebugDraw()
{
//ctor
std::cout << "Constructor - DebugDraw" << std::endl;
}
DebugDraw::~DebugDraw()
{
//dtor
}
void DebugDraw::DrawPolygon (const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)
{
SDL_Surface * screen = SDL_GetVideoSurface();
for(int i=0; i < vertexCount-1; i++)
{
lineRGBA( screen, vertices[i].x, vertices[i+1].x, vertices[i].y, vertices[i+1].y,
0, 255, 0, 255 );
}
lineRGBA( screen, vertices[vertexCount-1].x, vertices[0].x,
vertices[vertexCount-1].y, vertices[0].y,
0, 255, 0, 255 );
std::cout << "Drew Polygon" << std::endl;
}
void DebugDraw::DrawSolidPolygon (const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)
{
DrawPolygon( vertices, vertexCount, color);
std::cout << "Drew Solid Polygon" << std::endl;
}
void DebugDraw::DrawSegment (const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color)
{
std::cout << "Drawing Segment" << std::endl;
lineRGBA( SDL_GetVideoSurface(), p1.x, p2.x, p1.y, p2.y, 0, 0, 255, 255);
}
void DebugDraw::DrawCircle (const b2Vec2 ¢er, float32 radius, const b2Color &color)
{
circleRGBA( SDL_GetVideoSurface(), center.x, center.y, radius, 0, 255, 255, 255);
std::cout << "Drawing Solid Circle" << std::endl;
}
void DebugDraw::DrawSolidCircle (const b2Vec2 ¢er, float32 radius, const b2Vec2 &axis,const b2Color &color)
{
circleRGBA( SDL_GetVideoSurface(), center.x, center.y, radius, 0, 255, 255, 255);
}
void DebugDraw::DrawXForm (const b2XForm &xf)
{
std::cout << "Drawing XForm" << std::endl;
}
If someone is feeling really benevolent maybe they could add the code to a blank project on their system and try it out ? (I'm using SDL along with SDL_gfx )
🙂