Help! Need simple DebugDraw example for Windows

I need some help using Box2D's DebugDraw feature. I don't know what I'm doing wrong... but I've tried every example online and it just doesn't seem to work for me. I can't see any shapes.
I can compile and run the Box2D TEstbed and can see the objects so I know it's possible.

Basically what I am looking for is:
* Simple HelloWorld (nothing fancy) type example with just a simple shape
* Utilizes cocos2d-x and Box2D
* Builds and runs on Windows (I'm using VisualStudio 2012)

If you can whip up and share something like this, I would be forever gratefull. I've spent all week on this have haven't made an progress. 🙁

Thanks!!!
I don't know what you've looked up but for when setting up a debug draw, you need a way to draw it

I mainly write in java, however for C++ heres a video tutorial
https://www.youtube.com/watch?v=WbvwiGQSXSg

After you feel comfortable drawing shapes, you're going to want to extend the b2Draw class
https://github.com/ansman/box2d/blob/master/Box2D/Testbed/Framework/Render.h
And set the individual functions to draw to the 2d Rendering System of your choice
https://github.com/ansman/box2d/blob/master/Box2D/Testbed/Framework/Render.cpp

From there, you want to set the worlds DebugDraw via
Code:
m_world->SetDebugDraw(&m_debugDraw);

When setting up your world

Then in your step you'll want to do the function after your world step
Code:
m_world->DrawDebugData();


Again, I don't generally code in C++ but I'm confident once you can do this once, you wont have a problem with it ever again 🙂
Yep. That's exactly what I did but I must be missing something because no shapes show up. 🙁
Do you mind showing your main Class?
Sure.. here's my entire project so far what I have so far. I just used the create_project.py script to create a HelloWorld type cocos2d-x project and then added the Box2D stuff.
https://dl.dropboxusercontent.com/u/424 ... ameCpp.zip

Code:
#include "HelloWorldScene.h"

USING_NS_CC;

#define PTM_RATIO 32

HelloWorld::HelloWorld()
{
 this->initPhysics();
 scheduleUpdate();
 }

HelloWorld::~HelloWorld()
{
 delete world;
 world = NULL;

 delete debugDraw;
}

void HelloWorld::initPhysics()
{
 // Create our gravity vector
 b2Vec2 gravity;
 gravity.Set( 0.0f, 0.0f);

 // Create the world
 world = new b2World(gravity);

// Do we want to let bodies sleep?
 //world-> SetAllowSleeping( true);
 world-> SetContinuousPhysics(true);

 // Create our DebugDraw
 debugDraw = new DebugDraw(); 
 world->SetDebugDraw(debugDraw);

 uint32 flags = 0;
 flags += b2Draw::e_shapeBit;
 flags += b2Draw::e_jointBit;
 flags += b2Draw::e_aabbBit;
 flags += b2Draw::e_pairBit;
 flags += b2Draw::e_centerOfMassBit;

 debugDraw->SetFlags(flags);

 // Create a body
 b2BodyDef bodyDef;
 bodyDef.type = b2_dynamicBody;
 bodyDef.position.Set(20.0,20.0); // set position of circle

 // or make it static
 //bodyDef.type = b2_staticBody;
 b2Body *body = world->CreateBody(&bodyDef); 

 // create circle shape
 b2CircleShape circle;
 circle.m_radius = 20.0/PTM_RATIO;

 // define fixture
 b2FixtureDef fixtureDef;
 fixtureDef.shape = &circle;
 fixtureDef.density = 1;
 fixtureDef.restitution = 0.7;
 fixtureDef.friction = 0.4;

 body->CreateFixture(&fixtureDef);
}

void HelloWorld::draw()
{
 //
 // IMPORTANT:
 // This is only for debug purposes
 // It is recommend to disable it
 CCLayer::draw();
 ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
 kmGLPushMatrix();
 world->DrawDebugData();
 kmGLPopMatrix();
}

void HelloWorld::update( float dt)
{
 world->Step(dt, 8, 1);
}


CCScene* HelloWorld::scene()
{
    // 'scene' is an autorelease object
    CCScene *scene = CCScene::create();
   
    // 'layer' is an autorelease object
    HelloWorld *layer = HelloWorld::create();

    // add layer as a child to scene
    scene->addChild(layer);

    // return the scene
    return scene;
}

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
 return true;
}


void HelloWorld::menuCloseCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
   CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
    CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
#endif
}
Could you also show me the loop that you calling update in?

I want to make sure your calling
Code:
HelloWorld->draw()


Also if you could show me your debugdraw class, as its important for the debugdraw to know where it wants to draw to
Sure just follow the link in my post above... it has a *.zip file with my whole project.
Where are you running your main loop?

CCLayer has no method update nor does it have a method schedule update
How are you calling it from your helloworld?

http://www.cocos2d-iphone.org/api-ref/0.99.2/class_c_c_layer-members.html
I don't see how or when

Every Entry point needs a main even in cocos
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:hello_world

I feel as though the more I look through this, the more questions I have
This is cocos2d-x... not cocos2d-iphone. Not sure if that matters?
But in cocos2d-x, the CCLayer class has an update and scheduleUpdate method inherited from the CCObject parent class:
http://www.cocos2d-x.org/reference/nati ... layer.html
It seems that CC has its own draw methods, additionally are you sure opengl even has access to a window object.

I feel like I'm putting too much work into this, Try drawing without debug draw, then move it to debug draw
I don't want to leave you hanging but I also don't want to learn libraries I'm not using right now to solve someone elses problems

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