IOS Box2d version 2.1 DebugDraw not working

I am new to box2d, i have to deal with the Physics Engine. i am creating fixtures and Physics body and set position. Now i want to view physical objects in Debug Mode. i have visited many forums and tried code, but no luck.

i am using the following code after creating my world

    m_debugDraw = new GLESDebugDraw( PTM_RATIO );
    _world->SetDebugDraw(m_debugDraw);
    uint32 flags = 0;
    flags += b2Draw::e_shapeBit;
    flags += b2Draw::e_jointBit;
    flags += b2Draw::e_aabbBit;
    flags += b2Draw::e_pairBit;
    flags += b2Draw::e_centerOfMassBit;
    m_debugDraw->SetFlags(flags);

and also override the Draw method and included GLES_Render.h as well. there are no compile errors but Physics objects in debug mode are not showing.

-(void) draw
{
    [super draw];
    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
    kmGLPushMatrix();
    _world->DrawDebugData();
    kmGLPopMatrix();
}

how to enable Debug Draw using cocos2d/Box2d version 2.1 OR is there any alternate way to view physics objects ?

Thanks

Answers


You should use GLESDebugDraw when determining flags:

uint32 flags = 0;

flags += GLESDebugDraw::e_shapeBit;
flags += GLESDebugDraw::e_jointBit;
 .....
debugDraw->SetFlags(flags);

Need Your Help

Accessing a UISearchBar in a UIToolbar, in a UINavigationBar in UIAutomation

iphone ui-automation ios-ui-automation

We only support landscape mode and for some reason when we would push to a different view controller, rotate the app, then pop, our UISearchBar would then take up the entire navigationBar and pushing

add space top of wordpress page after include functions.php

wordpress function space

after paste functions.php in wordpress theme , add space top of page !